Best way to write an init.d script for start
I'm trying to come up with a nice init.d script that starts a psgi app, using start_server and starman. It needs to have the following features:
start-stop-daemon
is not available) start_server
as another user Ideally, I'd like to use the stuff that comes with /etc/init.d/functions
to give the script the look and feel of any ol' RedHat init.d script.
More specifically, I'm looking for best practices to:
--daemonize
option You could try runit, it's another supervisor. Nowdays it seems a good practice to use one of these things. Here you could read a comparison of different supervisors.
Best practices:
You don't have to daemonize the program, runit takes care of it.
Here you could use chpst
If perl is running anyway how about using Ubic ? It's a perl based supervisor that makes LSB /etc/init.d/ compatibility fairly easy. I tend to use it the way runit/daemontools/s6 are used (in a separate services/ directory) but you have a lot of flexibility. Since you can use perl in your scripts there's a lot of interesting possibilities. In addition Ubic gives you portability since it will work in the same way on different platforms (BSD, Linux, Solaris, OS/X, etc).
Here's the init script we're using: starman-init
It has all the features you mentioned:
Note that it assumes you have a local Perl installed for your application (such as plenv or perlbrew). You'll need to customize that for your environment.
链接地址: http://www.djcxy.com/p/13164.html上一篇: Sphinx的include ::指令和“重复标签”警告
下一篇: 编写init.d脚本的最佳方式