Skip to content

Commit

Permalink
fix: Handling SIGTERM in CLI start command (sourcenetwork#1459)
Browse files Browse the repository at this point in the history
## Relevant issue(s)

Resolves sourcenetwork#1458

## Description

Simply adds SIGTERM to the list of handled signals.

We can send send a signal,
`syscall.Kill(syscall.Getpid(), syscall.SIGINT)` within an integration
test but it will end the test process which also is running
the other tests.
It might require an 'external' integration test suite in which we can
run the command and then send the signal to the process.

## Tasks

- [x] I made sure the code is well commented, particularly
hard-to-understand areas.
- [x] I made sure the repository-held documentation is changed
accordingly.
- [x] I made sure the pull request title adheres to the conventional
commit style (the subset used in the project can be found in
[tools/configs/chglog/config.yml](tools/configs/chglog/config.yml)).
- [x] I made sure to discuss its limitations such as threats to
validity, vulnerability to mistake and misuse, robustness to
invalidation of assumptions, resource requirements, ...

## How has this been tested?

Manually
  • Loading branch information
orpheuslummis authored May 5, 2023
1 parent ca9f975 commit 12c73ae
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cli/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"os"
"os/signal"
"strings"
"syscall"

badger "github.com/dgraph-io/badger/v3"
grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
Expand Down Expand Up @@ -384,7 +385,7 @@ func start(ctx context.Context, cfg *config.Config) (*defraInstance, error) {
func wait(ctx context.Context, di *defraInstance) error {
// setup signal handlers
signalCh := make(chan os.Signal, 1)
signal.Notify(signalCh, os.Interrupt)
signal.Notify(signalCh, os.Interrupt, syscall.SIGTERM)

select {
case <-ctx.Done():
Expand Down

0 comments on commit 12c73ae

Please sign in to comment.