Skip to content

Commit

Permalink
fix stopsignal for go program.
Browse files Browse the repository at this point in the history
  • Loading branch information
m1k1o committed Sep 11, 2021
1 parent 6ee8bb8 commit b7950b3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .m1k1o/base/supervisord.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[supervisord]
nodaemon=true
user=root
pidfile=/var/run/supervisord.pid
logfile=/dev/null
logfile_maxbytes=0
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions server/neko.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

0 comments on commit b7950b3

Please sign in to comment.