File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -72,10 +72,8 @@ func main() {
7272 }
7373
7474 if * addr != "" {
75- stp := make (chan os.Signal , 1 )
76- signal .Notify (stp , os .Interrupt , syscall .SIGTERM )
77- ctx , ctxCancel := context .WithCancel (context .Background ())
78- defer ctxCancel ()
75+ ctx , cancel := signal .NotifyContext (context .Background (), os .Interrupt , syscall .SIGTERM )
76+ defer cancel ()
7977
8078 p := prometheus .NewPedanticRegistry ()
8179 p .MustRegister (prometheus .NewProcessCollector (prometheus.ProcessCollectorOpts {}))
@@ -97,9 +95,14 @@ func main() {
9795 log .Fatalln (err .Error ())
9896 }
9997 }()
100-
10198 log .Println ("exporter listening on:" , listener .Addr ().String ())
102- <- stp
103- h .Shutdown (ctx )
99+
100+ <- ctx .Done ()
101+
102+ t , tc := context .WithTimeout (context .Background (), 5 * time .Second )
103+ defer tc ()
104+ h .Shutdown (t )
105+
106+ log .Println ("exporter shutdown completed" )
104107 }
105108}
You can’t perform that action at this time.
0 commit comments