Best init script to run an application as a standalone user

I have an application that runs in a user account (based on Plack) and requires an init script.

It looks as simple as "sudo $ user start_server ...". I just wrote an LSB script using start-stop-daemon and it is really awkward and verbose. This does not seem to be the right way.

After doing a little searching and looking at a log of examples, I'm still not sure what the best way to do this is, and there is no consistent manual that I found.

I am currently working with:

start-stop-daemon --background --quiet --start --pidfile $PIDFILE \
                --make-pidfile --chuid $DAEMONUSER \
                --exec $DAEMON -- $DAEMON_OPTS

With DAEMON and DAEMON_OPTS like:

DAEMON="/home/mediamogul/perl5/perlbrew/perls/current/bin/start_server"
DAEMON_OPTS="--port $PORT -- starman --workers $WORKERS /home/mediamogul/MediaMogul/script/mediamogul.psgi"

Then I need to configure how to detect the launch, because it is a perl script, so perl is displayed as a command, not "start_server".

( perlbrew , perl, perl )

? , .

+5
1

--pid starman, PID , , start-stop-daemon, .

, init.d: ​​


SITENAME=mysite
PORT=5000
DIR=/websites/mysite
SCRIPT=bin/app.pl
USER=davidp

PIDFILE=/var/run/site-$SITENAME.pid

case "$1" in start) start-stop-daemon --start --chuid $USER --chdir $DIR \ --pidfile=$PIDFILE \ --exec /usr/local/bin/starman -- -p $PORT $SCRIPT -D --pid $PIDFILE ;; stop) start-stop-daemon --stop --pidfile $PIDFILE ;; *) echo "Usage: $SCRIPTNAME {start|stop}" >&2 exit 3 ;; esac

, , , , , - Starman PID , , start-stop-daemon .

+2

All Articles