Skip to content

Commit

Permalink
fix SystemV init script template for debian packaging
Browse files Browse the repository at this point in the history
For processes that manage their own pid file, they should define the `PIDFILE` variable (sourced either through `/etc/default/…` or `/etc/sysconfig/…`). Otherwise, if undefined, this script will capture the pid and write it to `/var/run/${{app_name}}/running.pid`.

This commit is related to 45bc5db that implements the same logic for rpm packaging
  • Loading branch information
yanns committed Nov 13, 2015
1 parent a870c7f commit 089bd32
Showing 1 changed file with 11 additions and 2 deletions.
Expand Up @@ -18,7 +18,12 @@ source /lib/lsb/init-functions
# $JAVA_OPTS used in $RUN_CMD wrapper
export JAVA_OPTS

PIDFILE=/var/run/${{app_name}}/running.pid
# If program manages its own PID file then it
# should declare its location in PIDFILE
if [ -z "$PIDFILE" ]; then
create_pidfile=true
PIDFILE=/var/run/${{app_name}}/running.pid
fi

if [ -z "$DAEMON_USER" ]; then
DAEMON_USER=${{daemon_user}}
Expand All @@ -35,7 +40,11 @@ RUN_CMD="${{chdir}}/bin/${{exec}}"
start_daemon() {
log_daemon_msg "Starting" "${{app_name}}"
[ -d "/var/run/${{app_name}}" ] || install -d -o "$DAEMON_USER" -g "$DAEMON_GROUP" -m755 "/var/run/${{app_name}}"
start-stop-daemon --background --chdir ${{chdir}} --chuid "$DAEMON_USER" --make-pidfile --pidfile "$PIDFILE" --startas "$RUN_CMD" --start -- $RUN_OPTS
if [ "$create_pidfile" = true ]; then
start-stop-daemon --background --chdir ${{chdir}} --chuid "$DAEMON_USER" --make-pidfile --pidfile "$PIDFILE" --startas "$RUN_CMD" --start -- $RUN_OPTS
else
start-stop-daemon --background --chdir ${{chdir}} --chuid "$DAEMON_USER" --pidfile "$PIDFILE" --startas "$RUN_CMD" --start -- $RUN_OPTS
fi
log_end_msg $?
}

Expand Down

0 comments on commit 089bd32

Please sign in to comment.