File tree Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -15,15 +15,14 @@ import (
15
15
"syscall"
16
16
"time"
17
17
18
- "go.opentelemetry.io/otel/codes"
19
-
18
+ "github.com/czerwonk/junos_exporter/internal/config"
20
19
"github.com/czerwonk/junos_exporter/pkg/connector"
21
20
22
21
"github.com/prometheus/client_golang/prometheus"
23
22
"github.com/prometheus/client_golang/prometheus/promhttp"
24
- log "github.com/sirupsen/logrus "
23
+ "go.opentelemetry.io/otel/codes "
25
24
26
- "github.com/czerwonk/junos_exporter/internal/config "
25
+ log "github.com/sirupsen/logrus "
27
26
)
28
27
29
28
const version string = "0.12.7"
@@ -126,12 +125,12 @@ func main() {
126
125
}
127
126
defer shutdownTracing ()
128
127
129
- initChannels ()
128
+ initChannels (ctx )
130
129
131
130
startServer ()
132
131
}
133
132
134
- func initChannels () {
133
+ func initChannels (ctx context. Context ) {
135
134
hup := make (chan os.Signal , 1 )
136
135
signal .Notify (hup , syscall .SIGHUP )
137
136
@@ -155,15 +154,21 @@ func initChannels() {
155
154
} else {
156
155
rc <- nil
157
156
}
157
+ case <- ctx .Done ():
158
+ shutdown ()
158
159
case <- term :
159
- log .Infoln ("Closing connections to devices" )
160
- connManager .Close ()
161
- os .Exit (0 )
160
+ shutdown ()
162
161
}
163
162
}
164
163
}()
165
164
}
166
165
166
+ func shutdown () {
167
+ log .Infoln ("Closing connections to devices" )
168
+ connManager .Close ()
169
+ os .Exit (0 )
170
+ }
171
+
167
172
func printVersion () {
168
173
fmt .Println ("junos_exporter" )
169
174
fmt .Printf ("Version: %s\n " , version )
You can’t perform that action at this time.
0 commit comments