Basic plackup/dancer startup script for Centos
Hi All, I have knocked up a very basic init script for centos, I suspect it will work for other RH derivatives also. It can be found at https://gist.github.com/1300467. Modify it to suit, rename it appropriately, place it in /etc/init.d. Test it works as expected with: service some_website start service some_website stop service some_website restart and then turn it on chkconfig some_website on Comments, changes, suggestions welcome. Cheers Matt
Good day, Matt! Thanks for nice job ;-) But i think the best way to describe exactly runlevels in init.d script If there will be '-' then "chkconfig service on" will create only start scripts for default runlevels '2345' but it will not create stop scripts for levels '016' (to checkup by seeing to ls -l /etc/rc.d/rc6.d/K* ;-) after chkconfig ... on) So if your some_website file will be included to a system start-up scripts through "chkconfig service on" command the Dancer application will be stopped at shutdown (6 runlevel) only by killall script by kill signal (i think better way by your 'stop' command - service some_website stop at stop priority as your '15') Perlover 2011/10/20 Matthew Vickers <mvickers@quispiam.com>:
Hi All,
I have knocked up a very basic init script for centos, I suspect it will work for other RH derivatives also.
It can be found at https://gist.github.com/1300467. Modify it to suit, rename it appropriately, place it in /etc/init.d. Test it works as expected with:
service some_website start
service some_website stop
service some_website restart
and then turn it on
chkconfig some_website on
Comments, changes, suggestions welcome.
Cheers
Matt _______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
Example here: https://gist.github.com/1300814/801cb19c76b2c7dbf6686bc2494d6869f19b3abe I forgot to add in previous letter :)
On 20/10/11 9:26 PM, Perlover wrote:
Good day, Matt! Hey Perlover
Thanks for nice job Thank you for saying so, it's the least I could do for such a nice community. But i think the best way to describe exactly runlevels in init.d script If there will be '-' then "chkconfig service on" will create only start scripts for default runlevels '2345' but it will not create stop scripts for levels '016' (to checkup by seeing to ls -l /etc/rc.d/rc6.d/K* after chkconfig ... on) So if your some_website file will be included to a system start-up scripts through "chkconfig service on" command the Dancer application will be stopped at shutdown (6 runlevel) only by killall script by kill signal (i think better way by your 'stop' command - service some_website stop at stop priority as your '15')
Perlover I have implemented your addition to the script and explicitly placed the runlevels of 2345 in the init script but am afraid I do not see the difference. This is most likely due to my ignorance of the SysV init system.
If I have #chkconfig: - 85 15 and perform chkconfig some_website on I get symlinks rc3.d/S85some_website, rc5.d/S85some_website, rc4.d/S85some_website and rc2.d/S85some_website If I have #chkconfig: 2345 85 15 and perform the same command I get exactly the same symlinks. I suppose my confusion comes from thinking there should be K15some_website symlinks in rc6.d and rc0.d for the halt and reboot runlevels. I found I can only get K15some_website if I perform a chkconfig some_website off Could you shed some more light on this subject please ? Cheers Matt
Hello!
chkconfig some_website on
I get symlinks rc3.d/S85some_website, rc5.d/S85some_website, rc4.d/S85some_website and rc2.d/S85some_website
Sorry for my English is not understandable ;-) In normal situation you should have a K15some_website symlinks in rc6.d and rc0.d after chkconfig some_website 'on' (for this you should have line as '#chkconfig: 2345...') Because when you will run shutdown command, your system will turn runlevel 3 -> 6 and will run kill scripts (K*) at 6 runlevel and than S* scripts (starts) But if you don't have exactly runlevels in your init.d script (you have only '-') you will have only S* symlinks in rc[2345].d (that you have) after chkconfig some_website 'on' I think a right thing that a init.d script should have stop symlinks in rc[06].d for normal program stopping
If I have #chkconfig: 2345 85 15 and perform the same command I get exactly the same symlinks.
Yes, i think it's normal behavior for right an init.d script :-) Otherwise our program will not be stopped correctly by shutdown - it will be killed by killall if /etc/init.d/killall will not help And if you described in your script stop priority level (15) i thought that you want to have a correctly stopped Dancer appliction. Sorry, it's not critical - your program is nice without this :)
I suppose my confusion comes from thinking there should be K15some_website symlinks in rc6.d and rc0.d for the halt and reboot runlevels. I found I can only get K15some_website if I perform a chkconfig some_website off
Could you shed some more light on this subject please ?
Cheers
Matt
_______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
On 20/10/11 10:52 PM, Perlover wrote:
Sorry for my English is not understandable ;-) That is perfectly alright ! I can understand OK, it's more my lack of knowledge about chkconfig and SysV than your English ! In normal situation you should have a K15some_website symlinks in rc6.d and rc0.d after chkconfig some_website 'on' (for this you should have line as '#chkconfig: 2345...') Because when you will run shutdown command, your system will turn runlevel 3 -> 6 and will run kill scripts (K*) at 6 runlevel and than S* scripts (starts) But if you don't have exactly runlevels in your init.d script (you have only '-') you will have only S* symlinks in rc[2345].d (that you have) after chkconfig some_website 'on' I think a right thing that a init.d script should have stop symlinks in rc[06].d for normal program stopping
If I have #chkconfig: 2345 85 15 and perform the same command I get exactly the same symlinks. Yes, i think it's normal behavior for right an init.d script :-) Otherwise our program will not be stopped correctly by shutdown - it will be killed by killall if /etc/init.d/killall will not help And if you described in your script stop priority level (15) i thought that you want to have a correctly stopped Dancer appliction. Thanks for explaining this in more detail, it now makes more sense. Sorry, it's not critical - your program is nice without this :) I should admit that the guts of this script was lifted form the nginx init script, and that's exactly what is in there. My reasoning was I want the dancer apps to start at around the same time as nginx.
cheers Matt.
participants (2)
-
Matthew Vickers -
Perlover