summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile3
-rw-r--r--argv.go1
-rw-r--r--event.go7
-rw-r--r--http.go7
-rw-r--r--main.go10
5 files changed, 23 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index ce95f92..a8e3983 100644
--- a/Makefile
+++ b/Makefile
@@ -9,6 +9,9 @@ all:
./virtigo --version
./virtigo --hosts farm01 farm02 farm03
+start:
+ ./virtigo --start jcarr
+
# this is for release builds using the go.mod files
release-build:
@echo ${REDOMOD}
diff --git a/argv.go b/argv.go
index 02e30b0..b656bee 100644
--- a/argv.go
+++ b/argv.go
@@ -15,6 +15,7 @@ type args struct {
Uptime bool `arg:"--uptime" default:"true" help:"allow uptime checks for things like Kuma"`
Port int `arg:"--port" default:"8080" help:"specify a different default port"`
Daemon bool `arg:"--daemon" help:"run in daemon mode"`
+ Start string `arg:"--start" help:"droplet to start"`
}
func (a args) Description() string {
diff --git a/event.go b/event.go
index ec47c6e..d554c78 100644
--- a/event.go
+++ b/event.go
@@ -1,6 +1,8 @@
package main
import (
+ "time"
+
"go.wit.com/lib/gui/shell"
"go.wit.com/log"
)
@@ -13,4 +15,9 @@ func (h *HyperT) RestartDaemon() {
url := "http://" + h.Hostname + ":2520/kill"
s := shell.Wget(url)
log.Info("EVENT RestartDaemon", url, s)
+ h.lastpoll = time.Now()
+ h.killcount += 1
+
+ dur := time.Since(h.lastpoll) // Calculate the elapsed time
+ log.Info("KILLED DAEMON", h.Hostname, shell.FormatDuration(dur), "curl", url)
}
diff --git a/http.go b/http.go
index 5bf5300..085757b 100644
--- a/http.go
+++ b/http.go
@@ -71,11 +71,8 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
url := "http://" + h.Hostname + ":2520/kill"
dur := time.Since(h.lastpoll) // Calculate the elapsed time
if dur > 90*time.Second {
- log.Info("KILL DAEMON ON", h.Hostname, shell.FormatDuration(dur), "curl", url)
- // s := shell.Wget(url)
- // log.Info("curl got:", s)
- h.lastpoll = time.Now()
- h.killcount += 1
+ h.RestartDaemon()
+ continue
}
if h.killcount != 0 {
log.Info("KILL count =", h.killcount, "FOR", h.Hostname, dur, "curl", url)
diff --git a/main.go b/main.go
index f7e14a6..ec698b9 100644
--- a/main.go
+++ b/main.go
@@ -46,6 +46,16 @@ func main() {
me.hypers = append(me.hypers, h)
}
+ if argv.Start != "" {
+ d := findDroplet(argv.Start)
+ if d == nil {
+ log.Info("droplet is unknown:", argv.Start)
+ } else {
+ log.Info("start droplet here:", d.Hostname)
+ }
+ os.Exit(0)
+ }
+
// start the watchdog polling for each hypervisor
for _, h := range me.hypers {
log.Info("starting watchdog here for hostname =", h.Hostname)