Graylog2 / fpm-recipes

Graylog package build recipes
http://docs.graylog.org/en/latest/pages/installation/operating_system_packages.html
18 stars 19 forks source link

Restart command does not work for Debian init script (server) #1

Closed bernd closed 9 years ago

bernd commented 10 years ago

The /etc/init.d/graylog2-server restart command does not work for Debian. Also check all others.

bernd commented 10 years ago

The script has to wait until the old process is gone before starting the new one.

bernd commented 10 years ago

Use start-stop-daemon.

--- graylog2-server 2014-06-20 07:13:21.000000000 -0700
+++ /etc/init.d/graylog2-server 2014-06-20 08:34:00.000000000 -0700
@@ -61,10 +61,11 @@
        chown ${GRAYLOG2_USER}:${GRAYLOG2_USER} /var/run/graylog2
    fi
    if running ; then
-       log_progress_msg "apparently already running"
+       [ "$VERBOSE" != no ] && log_progress_msg "apparently already running"
        return 1
    else
-       su -s /bin/bash -c "nohup $DAEMON $DAEMON_ARGS >> /var/log/graylog2-server/console.log 2>&1 &" ${GRAYLOG2_USER} || return 2
+       start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE --user $GRAYLOG2_USER \
+           --chuid $GRAYLOG2_USER --background --startas $DAEMON -- $DAEMON_ARGS
        sleep 2
        if running ; then
            return 0
@@ -76,11 +77,9 @@

 do_stop()
 {
-   if [ -s $PIDFILE ]; then
-       kill `cat ${PIDFILE}` >/dev/null 2>&1
-   fi
+   start-stop-daemon --stop --quiet --oknodo --user $GRAYLOG2_USER \
+       --retry=TERM/60/KILL/5 --pidfile $PIDFILE
    rm -f $PIDFILE
-   return "0"
 }

 case "$1" in
bernd commented 9 years ago

Fixed via c63ea89.