From 089bd3261379c47b0d022bdaa9ae23e9cd401ce5 Mon Sep 17 00:00:00 2001 From: Yann Simon Date: Fri, 13 Nov 2015 08:36:13 +0100 Subject: [PATCH] fix SystemV init script template for debian packaging MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 https://github.com/sbt/sbt-native-packager/commit/45bc5dbaffdca8eaef4b498c6b93e3e03350428d that implements the same logic for rpm packaging --- .../systemloader/systemv/start-debian-template | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/resources/com/typesafe/sbt/packager/archetypes/java_server/systemloader/systemv/start-debian-template b/src/main/resources/com/typesafe/sbt/packager/archetypes/java_server/systemloader/systemv/start-debian-template index 4872c65d3..b4d7f29a3 100644 --- a/src/main/resources/com/typesafe/sbt/packager/archetypes/java_server/systemloader/systemv/start-debian-template +++ b/src/main/resources/com/typesafe/sbt/packager/archetypes/java_server/systemloader/systemv/start-debian-template @@ -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}} @@ -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 $? }