Skip to content
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
7 changes: 4 additions & 3 deletions serve/destination.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os/signal"
"strings"
"sync"
"syscall"

pbv0 "github.com/cloudquery/plugin-sdk/internal/pb/destination/v0"
pbdiscoveryv0 "github.com/cloudquery/plugin-sdk/internal/pb/discovery/v0"
Expand Down Expand Up @@ -145,15 +146,15 @@ func newCmdDestinationServe(serve *destinationServe) *cobra.Command {
}
ctx := cmd.Context()
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
defer func() {
signal.Stop(c)
}()

go func() {
select {
case <-c:
logger.Info().Str("address", listener.Addr().String()).Msg("Got interrupt. Destination plugin server shutting down")
case sig := <-c:
logger.Info().Str("address", listener.Addr().String()).Str("signal", sig.String()).Msg("Got stop signal. Destination plugin server shutting down")
s.Stop()
case <-ctx.Done():
logger.Info().Str("address", listener.Addr().String()).Msg("Context cancelled. Destination plugin server shutting down")
Expand Down
7 changes: 4 additions & 3 deletions serve/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os/signal"
"strings"
"sync"
"syscall"

pbdiscoveryv0 "github.com/cloudquery/plugin-sdk/internal/pb/discovery/v0"
pbv0 "github.com/cloudquery/plugin-sdk/internal/pb/source/v0"
Expand Down Expand Up @@ -160,15 +161,15 @@ func newCmdSourceServe(serve *sourceServe) *cobra.Command {

ctx := cmd.Context()
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
defer func() {
signal.Stop(c)
}()

go func() {
select {
case <-c:
logger.Info().Str("address", listener.Addr().String()).Msg("Got interrupt. Source plugin server shutting down")
case sig := <-c:
logger.Info().Str("address", listener.Addr().String()).Str("signal", sig.String()).Msg("Got stop signal. Source plugin server shutting down")
s.Stop()
case <-ctx.Done():
logger.Info().Str("address", listener.Addr().String()).Msg("Context cancelled. Source plugin server shutting down")
Expand Down