Consul Agent received Caught second signal terminated. Exiting
- Dominant language
- Go
- Stars
- 30.1k
- Forks
- 4.6k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 43
Description
#### Overview of the Issue
Consul agent is getting a Second sigterm signal.
I am running consul agent using consul docker image. Docker image is build using the consul image. When container is stopped graceful exit is happening but i can see in the logs that a second sigterm is received by the consul agent. Not sure from where it's coming.
From the docker i am executing a shell script start.sh which runs consul agent command in background. In consul agent configuration i have enabled
```
leave_on_terminate = true
skip_leave_on_interrupt = false
```
for the graceful shutdown.
Since the consul agent command is running as a child process the sigterm won't be forwarded to consul agent process, so I have trapped the sigterm in start.sh and forward it to consul process.
```
graceful_shutdown() {
echo "SIGTERM received"
trap '' SIGTERM SIGINT # clear the trap
consul_pid=$(ps -ef | grep "consul agent" | grep -v grep | awk '{print $1}')
kill -SIGTERM ${consul_pid} # Sends SIGTERM to child/sub processes
wait
echo DONE
}
trap graceful_shutdown SIGTERM SIGINT
```
I am assuming that consul process will get the SIGTERM and perform a graceful shutdown.. In the logs however its logging a second SIGTERM which i am not sure from where its coming.
```
{"@level":"info","@message":"Caught second signal, Exiting","@module":"agent","@timestamp":"2022-05-05T18:08:44.327411Z","signal":15}
```
Consul Version: 1.11.1
Host OS: MacOS
Docker version 20.10.10, build b485636
Anyone has seen this issue earlier?
Contributor guide
Assessment
This issue has not been assessed yet.