Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add sigterm signal #1508

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading