daemon option works correctly

This commit is contained in:
Jeff Carr 2025-03-12 05:37:53 -05:00
parent c941ec541e
commit c2f796de1e
3 changed files with 13 additions and 13 deletions

View File

@ -24,6 +24,9 @@ sudo: build
debian: debian:
go-deb --repo go.wit.com/lib/daemons/gus go-deb --repo go.wit.com/lib/daemons/gus
daemon:
./gus --daemon --no-gui --config /etc/gus/gus.text
goimports: goimports:
goimports -w *.go goimports -w *.go

View File

@ -5,7 +5,7 @@ After=network.target
[Service] [Service]
User=root User=root
Type=simple Type=simple
ExecStart=/usr/bin/zood --daemon ExecStart=/usr/bin/gus --daemon --no-gui
Restart=always Restart=always
RestartSec=5s RestartSec=5s
KillMode=process KillMode=process

21
main.go
View File

@ -53,24 +53,24 @@ func main() {
if argv.Daemon { if argv.Daemon {
// turn off timestamps for STDOUT (systemd adds them) // turn off timestamps for STDOUT (systemd adds them)
log.DaemonMode(true) log.DaemonMode(true)
startGus()
startHTTP() startHTTP()
os.Exit(0) os.Exit(0)
} }
if gui.NoGui() { if gui.NoGui() {
all := me.portmaps.All() startGus()
for all.Scan() {
pm := all.Next()
if !pm.Enabled {
continue
}
log.Info("portmap enabled for port", pm.Localport, "to", pm.Dest)
go gus3000(pm)
}
startHTTP() startHTTP()
os.Exit(0) os.Exit(0)
} }
startGus()
// go NewWatchdog()
go startHTTP()
doGui()
}
func startGus() {
all := me.portmaps.All() all := me.portmaps.All()
for all.Scan() { for all.Scan() {
pm := all.Next() pm := all.Next()
@ -80,9 +80,6 @@ func main() {
log.Info("portmap enabled for port", pm.Localport, "to", pm.Dest) log.Info("portmap enabled for port", pm.Localport, "to", pm.Dest)
go gus3000(pm) go gus3000(pm)
} }
// go NewWatchdog()
go startHTTP()
doGui()
} }
// func doME(pm *Portmap, gus listener.Accept) { // func doME(pm *Portmap, gus listener.Accept) {