attempt to generate an event. next up: protobuf
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
268cec143a
commit
ca1a78394f
3
Makefile
3
Makefile
|
@ -9,6 +9,9 @@ all:
|
||||||
./virtigo --version
|
./virtigo --version
|
||||||
./virtigo --hosts farm01 farm02 farm03
|
./virtigo --hosts farm01 farm02 farm03
|
||||||
|
|
||||||
|
start:
|
||||||
|
./virtigo --start jcarr
|
||||||
|
|
||||||
# this is for release builds using the go.mod files
|
# this is for release builds using the go.mod files
|
||||||
release-build:
|
release-build:
|
||||||
@echo ${REDOMOD}
|
@echo ${REDOMOD}
|
||||||
|
|
1
argv.go
1
argv.go
|
@ -15,6 +15,7 @@ type args struct {
|
||||||
Uptime bool `arg:"--uptime" default:"true" help:"allow uptime checks for things like Kuma"`
|
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"`
|
Port int `arg:"--port" default:"8080" help:"specify a different default port"`
|
||||||
Daemon bool `arg:"--daemon" help:"run in daemon mode"`
|
Daemon bool `arg:"--daemon" help:"run in daemon mode"`
|
||||||
|
Start string `arg:"--start" help:"droplet to start"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a args) Description() string {
|
func (a args) Description() string {
|
||||||
|
|
7
event.go
7
event.go
|
@ -1,6 +1,8 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
"go.wit.com/lib/gui/shell"
|
"go.wit.com/lib/gui/shell"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
@ -13,4 +15,9 @@ func (h *HyperT) RestartDaemon() {
|
||||||
url := "http://" + h.Hostname + ":2520/kill"
|
url := "http://" + h.Hostname + ":2520/kill"
|
||||||
s := shell.Wget(url)
|
s := shell.Wget(url)
|
||||||
log.Info("EVENT RestartDaemon", url, s)
|
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)
|
||||||
}
|
}
|
||||||
|
|
7
http.go
7
http.go
|
@ -71,11 +71,8 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
url := "http://" + h.Hostname + ":2520/kill"
|
url := "http://" + h.Hostname + ":2520/kill"
|
||||||
dur := time.Since(h.lastpoll) // Calculate the elapsed time
|
dur := time.Since(h.lastpoll) // Calculate the elapsed time
|
||||||
if dur > 90*time.Second {
|
if dur > 90*time.Second {
|
||||||
log.Info("KILL DAEMON ON", h.Hostname, shell.FormatDuration(dur), "curl", url)
|
h.RestartDaemon()
|
||||||
// s := shell.Wget(url)
|
continue
|
||||||
// log.Info("curl got:", s)
|
|
||||||
h.lastpoll = time.Now()
|
|
||||||
h.killcount += 1
|
|
||||||
}
|
}
|
||||||
if h.killcount != 0 {
|
if h.killcount != 0 {
|
||||||
log.Info("KILL count =", h.killcount, "FOR", h.Hostname, dur, "curl", url)
|
log.Info("KILL count =", h.killcount, "FOR", h.Hostname, dur, "curl", url)
|
||||||
|
|
10
main.go
10
main.go
|
@ -46,6 +46,16 @@ func main() {
|
||||||
me.hypers = append(me.hypers, h)
|
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
|
// start the watchdog polling for each hypervisor
|
||||||
for _, h := range me.hypers {
|
for _, h := range me.hypers {
|
||||||
log.Info("starting watchdog here for hostname =", h.Hostname)
|
log.Info("starting watchdog here for hostname =", h.Hostname)
|
||||||
|
|
Loading…
Reference in New Issue