Skip to content

Commit

Permalink
Merge pull request #697 from yanns/debian_start_script_PIDFILE
Browse files Browse the repository at this point in the history
fix SystemV init script template for debian packaging
  • Loading branch information
kardapoltsev committed Nov 19, 2015
2 parents a870c7f + a824e09 commit 301dea4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
Expand Up @@ -2,7 +2,7 @@
# ##### Environment Configuration #####
# #####################################

# This file gets sourced before the actual bashscript
# This file gets sourced before the actual startscript
# gets executed. You can use this file to provide
# environment variables

Expand Down
Expand Up @@ -12,13 +12,19 @@
source /lib/init/vars.sh
source /lib/lsb/init-functions

# adding bashScriptEnvConfigLocation
# Source from package defined config. Defaults to,
# bashScriptEnvConfigLocation := Some("/etc/default/" + (packageName in Linux).value)
[[ -f ${{env_config}} ]] && . ${{env_config}}

# $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 +41,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 All @@ -44,7 +54,9 @@ stop_daemon() {
log_daemon_msg "Stopping" "${{app_name}}"
start-stop-daemon --stop --quiet --oknodo --pidfile "$PIDFILE" --retry=TERM/${{term_timeout}}/KILL/${{kill_timeout}}
log_end_msg $?
rm -f "$PIDFILE"
if [ "$create_pidfile" = true ]; then
rm -f "$PIDFILE"
fi
}

case "$1" in
Expand Down
6 changes: 3 additions & 3 deletions src/sphinx/topics/play.rst
Expand Up @@ -50,10 +50,10 @@ One way to provide this information is to append the following content in your b
This way you should either store your production configuration under ``${{path_to_app_name}}/conf/production.conf``
or put it under ``/usr/share/${{app_name}}/conf/production.conf`` by hand or using some configuration management system.

RPM and SystemV
~~~~~~~~~~~~~~~
SystemV
~~~~~~~

If you use a system with rpm as a packaging managing system (Fedora, CentOS, RedHat,...) make sure to provide
If you use a system using SystemV start script make sure to provide
a `etc-default` in `src/templates` and set the `PIDFILE` environment variable.


Expand Down

0 comments on commit 301dea4

Please sign in to comment.