Skip to content

Commit

Permalink
Merge pull request #1508 from rfyiamcool/main
Browse files Browse the repository at this point in the history
fix: add sigterm signal
  • Loading branch information
weizhoublue authored Oct 31, 2024
2 parents 81907e9 + 9965b42 commit ffff9c9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 6 additions & 4 deletions cmd/agent/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ package cmd
import (
"context"
"fmt"
"github.com/spf13/cobra"
"github.com/spidernet-io/egressgateway/pkg/agent"
"github.com/spidernet-io/egressgateway/pkg/config"
"os"
"os/signal"
"path/filepath"
"syscall"

"github.com/spf13/cobra"
"github.com/spidernet-io/egressgateway/pkg/agent"
"github.com/spidernet-io/egressgateway/pkg/config"
)

var binName = filepath.Base(os.Args[0])
Expand All @@ -21,7 +23,7 @@ var rootCmd = &cobra.Command{
Use: binName,
Short: "run egress gateway agent",
Run: func(cmd *cobra.Command, args []string) {
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt)
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
defer stop()

cfg, err := config.LoadConfig(true)
Expand Down
3 changes: 2 additions & 1 deletion cmd/controller/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"os"
"os/signal"
"path/filepath"
"syscall"

"github.com/spf13/cobra"

Expand All @@ -23,7 +24,7 @@ var rootCmd = &cobra.Command{
Use: binName,
Short: "run egress gateway controller",
Run: func(cmd *cobra.Command, args []string) {
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt)
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
defer stop()

cfg, err := config.LoadConfig(false)
Expand Down

0 comments on commit ffff9c9

Please sign in to comment.