feat: support --abort for reload and suspend (#346)

This commit is contained in:
mzz
2023-11-14 16:26:33 +08:00
committed by GitHub
parent 7e57531f91
commit 9f7a49b81d
5 changed files with 39 additions and 1 deletions

View File

@ -17,6 +17,7 @@ import (
)
var (
abort bool
reloadCmd = &cobra.Command{
Use: "reload [pid]",
Short: "To reload config file without interrupt connections.",
@ -35,6 +36,11 @@ var (
cmd.Help()
os.Exit(1)
}
if abort {
if f, err := os.Create(AbortFile); err == nil {
f.Close()
}
}
if err = syscall.Kill(pid, syscall.SIGUSR1); err != nil {
fmt.Println(err)
os.Exit(1)
@ -46,4 +52,5 @@ var (
func init() {
rootCmd.AddCommand(reloadCmd)
reloadCmd.PersistentFlags().BoolVarP(&abort, "abort", "a", false, "Abort established connections.")
}