From 8ae3fce581ef967e6c3d170a5ac5f751197a0501 Mon Sep 17 00:00:00 2001 From: mckaygerhard Date: Fri, 19 Feb 2021 14:42:04 -0400 Subject: [PATCH] Fix sysvinit script crash and not working, fixed #8 * the real process is a perl process as xplained in https://github.com/h2o/h2o/issues/84#issuecomment-68315426 so we need to point in the start-and-stop-daemon to property managed.. so in init scritp is commented and fixed the functions * starts a set of superdaemon program (named start_server) and a support library written in Perl, for hot-deploying TCP servers so the provided init script does nothing cos does not point real process --- src/debian/h2o.init | 47 +++++++++++++++------------------------------ 1 file changed, 16 insertions(+), 31 deletions(-) diff --git a/src/debian/h2o.init b/src/debian/h2o.init index 2d7e190..b30af03 100644 --- a/src/debian/h2o.init +++ b/src/debian/h2o.init @@ -5,8 +5,9 @@ # Required-Stop: $local_fs $network $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 -# Short-Description: start and stop h2o HTTP Server -# Description: H2O - the optimized HTTP/1, HTTP/2 server +# Short-Description: Optimized HTTP/1.x, HTTP/2 server +# Description: Manages the h2o daemon, the optimized HTTP/1.x and HTTP/2 +# server. ### END INIT INFO # Author: Tatsushi Demachi @@ -15,7 +16,7 @@ # PATH should only include /usr/* if it runs after the mountnfs.sh script PATH=/sbin:/usr/sbin:/bin:/usr/bin -DESC="h2o" +DESC="optimized HTTP/1 HTTP/2 server" NAME=h2o CONFIG_FILE=/etc/h2o/h2o.conf DAEMON=/usr/sbin/h2o @@ -47,7 +48,7 @@ fi # do_start() { - # Return + # the real daemon start by a perl implementation so we trap the return as: # 0 if daemon has been started # 1 if daemon was already running # 2 if daemon could not be started @@ -56,18 +57,6 @@ do_start() start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \ $DAEMON_ARGS \ || return 2 - # The above code will not work for interpreted scripts, use the next - # six lines below instead (Ref: #643337, start-stop-daemon(8) ) - #start-stop-daemon --start --quiet --pidfile $PIDFILE --startas $DAEMON \ - # --name $NAME --test > /dev/null \ - # || return 1 - #start-stop-daemon --start --quiet --pidfile $PIDFILE --startas $DAEMON \ - # --name $NAME -- $DAEMON_ARGS \ - # || return 2 - - # Add code here, if necessary, that waits for the process to be ready - # to handle requests from services started subsequently which depend - # on this one. As a last resort, sleep for some time. } # @@ -75,12 +64,11 @@ do_start() # do_stop() { - # Return - # 0 if daemon has been stopped - # 1 if daemon was already stopped - # 2 if daemon could not be stopped - # other if a failure occurred - start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME + # the starting of the server is xplained here https://github.com/h2o/h2o/issues/84#issuecomment-68315426 + # is a perl process in fact.. is a set of superdaemon program (named start_server) + # and a support library written in Perl, for hot-deploying TCP servers, + # so the perl process is the real program to kill but only with pid reported by h2o: + start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --exec /usr/bin/perl RETVAL="$?" [ "$RETVAL" = 2 ] && return 2 # Wait for children to finish too if this is a daemon that forks @@ -89,7 +77,7 @@ do_stop() # that waits for the process to drop all resources that could be # needed by services started subsequently. A last resort is to # sleep for some time. - start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON + start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --pidfile $PIDFILE --exec /usr/bin/perl [ "$?" = 2 ] && return 2 # Many daemons don't delete their pidfiles when they exit. rm -f $PIDFILE @@ -107,13 +95,11 @@ do_configtest() { # Function that sends a SIGHUP to the daemon/service # do_reload() { - # - # If the daemon can reload its configuration without - # restarting (for example, when it is sent a SIGHUP), - # then implement that here. - # - start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME - return 0 + # as the running h2o is started by a perl process, (from the start_server) + # so the perl process is the real program to send the signal: + log_daemon_msg "Reloading $DESC configuration files" "$NAME" + start-stop-daemon --oknodo --stop --signal HUP --quiet --pidfile "$PIDFILE" --exec "/usr/bin/perl" + log_end_msg $? } case "$1" in @@ -177,7 +163,6 @@ case "$1" in log_end_msg $? ;; *) - #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 echo "Usage: $SCRIPTNAME {start|stop|status|restart|reload|force-reload|configtest}" >&2 exit 3 ;;