Skip to content

Commit

Permalink
Fix handling of os signals in tink server
Browse files Browse the repository at this point in the history
Previously tink server failed to respect os signals like SIGTERM,SIGINT etc.

This PR fixes the tink server so that os signals sent to the tink server process
will actually kill the process.

Confirmed by runnning in docker-cpompose env:

```bash
make images
make run
docker exec -it tink_tinkerbell_1 sh
ps
kill -SIGINT 1
```

Corresponding logs:

```
tinkerbell_1             | {"level":"info","ts":1630442128.6128566,"caller":"tink-server/main.go:198","msg":"signal received, stopping servers","service":"github.com/tinkerbell/tink","signal":"interrupt"}
tinkerbell_1             | {"level":"info","ts":1630442129.4250214,"caller":"metrics/metrics.go:58","msg":"initializing label values","service":"github.com/tinkerbell/tink"}
tinkerbell_1             | {"level":"info","ts":1630442129.4286315,"caller":"http-server/http_server.go:88","msg":"serving http","service":"github.com/tinkerbell/tink"}
```

Now the docker container exists and we can see the log that signal is received.

Signed-off-by: Archana krishnan <[email protected]>
  • Loading branch information
krishnanarchana committed Sep 1, 2021
1 parent b547d22 commit 81ac85c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/tink-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,12 @@ func NewRootCommand(config *DaemonConfig, logger log.Logger) *cobra.Command {
HTTPBasicAuthPassword: config.HTTPBasicAuthPassword,
}, errCh)

<-ctx.Done()
select {
case err = <-errCh:
logger.Error(err)
case sig := <-sigs:
logger.With("signal", sig.String()).Info("signal received, stopping servers")
closer()
}

// wait for grpc server to shutdown
Expand Down

0 comments on commit 81ac85c

Please sign in to comment.