prometheus / prometheus/exporter-toolkit
Signal handling
Open
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 311
- Forks
- 109
- Avg merge
- 3d 59m
- Merged PRs (30d)
- 6
Description
Would like to see signal processing for SIGQUIT and SIGTERM in subsequent versions for proper systemd unit operation. Currently, the systemd unit transitions to a failed state after stopping the service.
Here is a short patch for version 0.21.0:
--- main.go.orig 2023-05-24 16:14:47.781711964 +0300
+++ main.go 2023-05-24 14:09:05.000000000 +0300
@@ -181,6 +181,22 @@
hup := make(chan os.Signal, 1)
reloadCh = make(chan chan error)
signal.Notify(hup, syscall.SIGHUP)
+ term_chan := make(chan os.Signal, 1)
+ signal.Notify(term_chan, syscall.SIGTERM, syscall.SIGQUIT)
+ go func(s <-chan os.Signal) {
+ for {
+ sig := <-s
+ switch sig {
+ case syscall.SIGTERM:
+ level.Info(logger).Log("msg", "Got SIGTERM. Exiting")
+ os.Exit(0)
+ case syscall.SIGQUIT:
+ level.Info(logger).Log("msg", "Got SIGQUIT. Exiting")
+ os.Exit(0)
+ }
+ }
+ }(term_chan)
+
go func() {
for {
select {
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in main.go around the signal setup near line 181 and review the provided patch in the issue. Confirm the service handles SIGTERM and SIGQUIT as intended, then verify that stopping the systemd unit no longer leaves it in a failed state.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- operating-systems
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100