internal: don't send kill signal to child as we mange it
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
7cbe33d65d
commit
311ffa9f79
|
@ -50,7 +50,7 @@ func main() {
|
|||
|
||||
<-ex
|
||||
log.WithField("logger", "authentik").Debug("shutting down webserver")
|
||||
ws.Shutdown()
|
||||
go ws.Shutdown()
|
||||
log.WithField("logger", "authentik").Debug("killing gunicorn")
|
||||
g.Kill()
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package gounicorn
|
|||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"syscall"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"goauthentik.io/internal/config"
|
||||
|
@ -12,6 +13,7 @@ type GoUnicorn struct {
|
|||
log *log.Entry
|
||||
p *exec.Cmd
|
||||
started bool
|
||||
killed bool
|
||||
}
|
||||
|
||||
func NewGoUnicorn() *GoUnicorn {
|
||||
|
@ -19,6 +21,7 @@ func NewGoUnicorn() *GoUnicorn {
|
|||
g := &GoUnicorn{
|
||||
log: logger,
|
||||
started: false,
|
||||
killed: false,
|
||||
}
|
||||
g.initCmd()
|
||||
return g
|
||||
|
@ -33,14 +36,21 @@ func (g *GoUnicorn) initCmd() {
|
|||
}
|
||||
g.log.WithField("args", args).WithField("cmd", command).Debug("Starting gunicorn")
|
||||
g.p = exec.Command(command, args...)
|
||||
g.p.Env = append(os.Environ(),
|
||||
"WORKERS=2",
|
||||
)
|
||||
g.p.Env = os.Environ()
|
||||
// Don't pass ctrl-c to child
|
||||
// since we handle it ourselves
|
||||
g.p.SysProcAttr = &syscall.SysProcAttr{
|
||||
Setpgid: true,
|
||||
}
|
||||
g.p.Stdout = os.Stdout
|
||||
g.p.Stderr = os.Stderr
|
||||
}
|
||||
|
||||
func (g *GoUnicorn) Start() error {
|
||||
if g.killed {
|
||||
g.log.Info("Not restarting gunicorn since we're killed")
|
||||
return nil
|
||||
}
|
||||
if g.started {
|
||||
g.initCmd()
|
||||
}
|
||||
|
@ -49,5 +59,6 @@ func (g *GoUnicorn) Start() error {
|
|||
}
|
||||
|
||||
func (g *GoUnicorn) Kill() error {
|
||||
g.killed = true
|
||||
return g.p.Process.Kill()
|
||||
}
|
||||
|
|
Reference in New Issue