Skip to content

Commit 0e0f126

Browse files
committed
slightly better output for monitor
fixes: #14
1 parent dde817f commit 0e0f126

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

commands/monitor.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,15 @@ var (
2121

2222
func waitForTerm(sigChan <-chan os.Signal) {
2323
<-sigChan
24-
fmt.Println("\r\n👋")
2524

2625
if config.MonitorWebhook != "" {
2726
hook := exec.Command("curl", "-H", "Content-type: application/json", "-d", `{"content": "stopped monitoring"}`,
2827
config.MonitorWebhook)
2928
hook.Run()
3029
}
3130

31+
fmt.Println("\r\n👋")
32+
3233
os.Exit(0)
3334
}
3435

@@ -138,6 +139,15 @@ func Monitor(args []string) {
138139

139140
fmt.Printf(theme.ColorGray+"interval: "+theme.ColorYellow+"%v seconds"+theme.ColorReset+"\n", montitorScanInterval)
140141

142+
if config.MonitorWebhook != "" {
143+
msg := fmt.Sprintf(`{"content": "starting monitoring: %s"}`, serverAddress)
144+
hook := exec.Command("curl", "-H", "Content-type: application/json", "-d", msg,
145+
config.MonitorWebhook)
146+
hook.Run()
147+
}
148+
149+
time.Sleep(time.Second * 5)
150+
141151
sigChan := make(chan os.Signal, 1)
142152
signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM)
143153

@@ -148,13 +158,6 @@ func Monitor(args []string) {
148158
fmt.Printf(theme.ColorGray+"starting scan: "+theme.ColorReset+"%v\n", time.Now().UTC())
149159
fmt.Println(theme.ColorPurple + "press " + theme.ColorCyan + "ctrl+c " + theme.ColorPurple + "to exit..." + theme.ColorReset)
150160

151-
if config.MonitorWebhook != "" {
152-
msg := fmt.Sprintf(`{"content": "starting monitoring: %s"}`, serverAddress)
153-
hook := exec.Command("curl", "-H", "Content-type: application/json", "-d", msg,
154-
config.MonitorWebhook)
155-
hook.Run()
156-
}
157-
158161
go monitorSpinner()
159162

160163
select {}

0 commit comments

Comments
 (0)