From b7950b3650807a8f3ba05d1b0df6af218e098136 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Sat, 11 Sep 2021 18:15:12 +0200 Subject: [PATCH] fix stopsignal for go program. --- .m1k1o/base/supervisord.conf | 3 +++ README.md | 1 + server/neko.go | 4 ++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.m1k1o/base/supervisord.conf b/.m1k1o/base/supervisord.conf index 3df95644..1bd7602b 100644 --- a/.m1k1o/base/supervisord.conf +++ b/.m1k1o/base/supervisord.conf @@ -1,5 +1,6 @@ [supervisord] nodaemon=true +user=root pidfile=/var/run/supervisord.pid logfile=/dev/null logfile_maxbytes=0 @@ -44,6 +45,8 @@ redirect_stderr=true [program:neko] environment=HOME="/home/%(ENV_USER)s",USER="%(ENV_USER)s",DISPLAY="%(ENV_DISPLAY)s" command=/usr/bin/neko serve --static "/var/www" +stopsignal=INT +stopwaitsecs=5 autorestart=true priority=800 user=%(ENV_USER)s diff --git a/README.md b/README.md index a8c128de..f972437b 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ For n.eko room management software, visit https://github.com/m1k1o/neko-rooms. - Full-screen support for iOS devices. - Added `chrome-sandbox` to fix weird bug when chromium didn't start. - Fixed keyboard mapping on macOS, when CMD could not be used for copy & paste. +- Fixed stop signal sent by supervisor to gracefully shut down neko server. ### Misc - Custom docker workflow. diff --git a/server/neko.go b/server/neko.go index a2d638ce..93a93b55 100644 --- a/server/neko.go +++ b/server/neko.go @@ -174,11 +174,11 @@ func (neko *Neko) ServeCommand(cmd *cobra.Command, args []string) { neko.Start() neko.logger.Info().Msg("neko ready") - quit := make(chan os.Signal) + quit := make(chan os.Signal, 1) signal.Notify(quit, os.Interrupt) sig := <-quit - neko.logger.Warn().Msgf("received %s, attempting graceful shutdown: \n", sig) + neko.logger.Warn().Msgf("received %s, attempting graceful shutdown", sig) neko.Shutdown() neko.logger.Info().Msg("shutdown complete") }