diff options
Diffstat (limited to 'connector')
-rw-r--r-- | connector/external/external.go | 16 | ||||
-rw-r--r-- | connector/mattermost/mattermost.go | 2 |
2 files changed, 10 insertions, 8 deletions
diff --git a/connector/external/external.go b/connector/external/external.go index b66ab6c..9896750 100644 --- a/connector/external/external.go +++ b/connector/external/external.go @@ -177,6 +177,7 @@ func (ext *External) restartLoop(generation int) { break } log.Printf("Process %s stopped, restarting.", ext.command) + log.Printf("Generation %d vs %d", ext.generation, generation) err := ext.setupProc(generation) if err != nil { ext.proc = nil @@ -326,22 +327,23 @@ func (ext *External) Close() { ext.sendJson.Encode(&extMessage{ MsgType: CLOSE, }) + ext.proc.Process.Signal(os.Interrupt) - proc := ext.proc - proc.Process.Signal(os.Interrupt) ext.recvPipe.Close() ext.sendPipe.Close() + go func() { + time.Sleep(1 * time.Second) + log.Info("Sending SIGKILL to external process (did not terminate within 1 second)") + ext.proc.Process.Kill() + }() + ext.proc.Wait() + ext.proc = nil ext.recvPipe = nil ext.sendPipe = nil ext.sendJson = nil ext.handlerChan = nil - - go func() { - time.Sleep(1 * time.Second) - proc.Process.Kill() - }() } // ---- Actual message handling :) diff --git a/connector/mattermost/mattermost.go b/connector/mattermost/mattermost.go index 0a632a9..ea49fd2 100644 --- a/connector/mattermost/mattermost.go +++ b/connector/mattermost/mattermost.go @@ -59,7 +59,7 @@ func (mm *Mattermost) Configure(c Configuration) error { } // Reinitialize shared data structures - mm.handlerStopChan = make(chan bool) + mm.handlerStopChan = make(chan bool, 1) mm.caches.mmusers = make(map[string]string) mm.caches.sentjoined = make(map[string]bool) |