Hi Stephen, Am 14.12.2017 um 01:14 schrieb Stephen Rothwell: > The sysv init script will fail to do a stop or restart:
Thanks a lot for all the bugreports regarding the init script. As you might have seen, the initscript didn't get much testing yet. PEB and me both use systemd and it seems like we neglected the sysvinit script. > > --die-on-term is passed to uwsgi, so a TERM signal is needed > to stop it instead of HUP That's a valid point. I now looked into the sysvinit script uswgi-core[1] again as reference and it uses '--retry=QUIT/30/KILL/5'. > uwsgi takes some time to terminate, so a following start may fail > if it is still stopping > stop sill fail if uwsgi is not actually running (which makes > restart fail) > > To fix all this, I changed do_stop to do: > > start-stop-daemon --stop --quiet --oknodo --retry forever/TERM/5 \ > --pidfile $PIDFILE --exec $DAEMON > > The "forever" may not be a good choice ... maybe "TERM/5/KILL/5" or > some such would be better. And 5 seconds may also not be a good choice, > but it seems to work fairly well on my setup. I don't like to use 'forever'. Something like 'QUIT/30/KILL/5' looks way better: It sends the 'QUIT' signal, waits for 30 seconds and then sends the KILL signal (waiting for 5 seconds). If neither succeeds, the stop process fails. That seems sensible to me. > I am also not sure that the {forced-}reload actions are going to work. Indeed, I updated them as well according to the uwsgi-core sysvinit script[1]. Could you give that attached updated init script a try and report back? Please test all of the start/stop/restart/reload/force-reload functions. > Also, maybe start-stop-daemon is not needed for uwsgi as it seems to do > its own process management? Not sure about that. The uwsgi package uses start-stop-daemon as well. As that's the common way to handle daemons with sysvinit in Debian, I think we should stick to it. Cheers jonas [1] https://sources.debian.org/src/uwsgi/2.0.15-10/debian/uwsgi-core.init.d.custom/
#!/bin/sh ### BEGIN INIT INFO # Provides: mailman3-suite # Required-Start: $network $local_fs $remote_fs $syslog # Required-Stop: $remote_fs # Should-Start: postgresql # Should-Stop: postgresql # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Mailman3 suite uWSGI service # Description: Mailman3 suite uWSGI service ### END INIT INFO PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin NAME="mailman3-suite" DESC="Mailman3 suite uWSGI service" SCRIPTNAME=/etc/init.d/mailman3-suite DAEMON=/usr/bin/uwsgi PIDFILE="/run/mailman3-suite/${NAME}.pid" LOGFILE="/var/log/mailman3/mailman3-suite.log" DAEMON_ARGS="--ini /usr/share/mailman3-suite/uwsgi.ini --die-on-term --pidfile ${PIDFILE} --daemonize ${LOGFILE}" test -x $DAEMON || exit 0 . /lib/lsb/init-functions if [ ! -d /run/mailman3-suite ]; then mkdir -p /run/mailman3-suite fi chown www-data:www-data /run/mailman3-suite do_start () { start-stop-daemon --start --quiet --pidfile $PIDFILE \ --exec $DAEMON --test >/dev/null|| return 1 start-stop-daemon --start --quiet --pidfile $PIDFILE \ --exec $DAEMON -- $DAEMON_ARGS || return 2 } do_stop () { start-stop-daemon --stop --quiet --oknodo --retry=QUIT/30/KILL/5 \ --pidfile $PIDFILE --exec $DAEMON } do_reload () { start-stop-daemon --stop --quiet --signal=HUP \ --pidfile $PIDFILE --exec $DAEMON RETVAL="$?" # There is no such process, nothing to reload! [ "$RETVAL" = 1 ] && RETVAL=3 return "$RETVAL" } do_force_reload() { start-stop-daemon --stop --quiet \ --signal=TERM \ --pidfile $PIDFILE \ --exec $DAEMON RETVAL="$?" # There is no such process, nothing to reload! [ "$RETVAL" = 1 ] && RETVAL=3 return "$RETVAL" } case "$1" in start) log_daemon_msg "Starting $DESC" "$NAME" do_start log_end_msg "$?" ;; stop) log_daemon_msg "Stopping $DESC" "$NAME" do_stop log_end_msg "$?" ;; status) status_of_proc -p "$PIDFILE" "$DAEMON" "$NAME" \ && exit 0 || exit $? ;; reload) log_daemon_msg "Reloading $DESC" "$NAME" do_reload log_end_msg "$?" ;; force-reload) log_daemon_msg "Forced reloading $DESC" "$NAME" do_force_reload log_end_msg "$RETVAL" ;; restart) log_daemon_msg "Restarting $DESC" "$NAME" do_stop case "$?" in 0) do_start log_end_msg "$?" ;; *) # Failed to stop log_end_msg 1 ;; esac ;; *) echo "Usage: $SCRIPTNAME {start|stop|status|restart|reload|force-reload}" >&2 exit 3 ;; esac
signature.asc
Description: OpenPGP digital signature