handle signals and explicitly stop the commands
@@ -13,10 +13,12 @@ import (
"log"
"os"
"os/exec"
+ "os/signal"
"path/filepath"
"runtime"
"strings"
"sync"
+ "syscall"
"time"
"github.com/spf13/cobra"
@@ -384,6 +386,21 @@ func serve() {
}
}()
+ sigc := make(chan os.Signal, 1)
+ signal.Notify(sigc,
+ syscall.SIGHUP,
+ syscall.SIGINT,
+ syscall.SIGTERM,
+ syscall.SIGQUIT)
+
+ wg.Add(1)
+ go func() {
+ defer wg.Done()
+ <-sigc
+ uiCmd.Process.Signal(syscall.SIGQUIT)
+ serverCmd.Process.Signal(syscall.SIGQUIT)
+ }()
+
wg.Wait()
}
