Added webserver flag for starting one

Later when the testing is done, the webserver will be enabled by default in the
config. This will allow the user to decide which mode they want to use.
experimental
Justin Reichardt 2022-08-19 19:10:11 -05:00
parent 2ad62c43c0
commit 3564aea1fc
2 changed files with 7 additions and 4 deletions

View File

@ -51,12 +51,14 @@ const GPL = `
func main() {
exit := make(chan bool)
var webserver bool = false
var daemon bool = false
var interval int = 1440
var versionflag bool = false
var removetimestamp bool = false
// Parsing Flags
flag.BoolVar(&webserver, "s", false, "Turn on the Webserver")
flag.BoolVar(&daemon, "d", false, "Should this be run in daemon mode")
flag.IntVar(&interval, "t", 1440, "Minutes until next run of daemon")
flag.BoolVar(&versionflag, "version", false, "show version information")
@ -83,8 +85,10 @@ func main() {
}
// Starting web server
go serve.Start(exit)
if (webserver == true){
go serve.Start(exit)
defer func(){<-exit}()
}
// Update the hosts file
if daemon == false {
err := hosts.Update()
@ -112,5 +116,4 @@ func main() {
}
}
}
<-exit
}

View File

@ -10,7 +10,7 @@ import (
func Start(exit chan bool) {
config := cfg.Create()
if config.WebServer.Enabled == false {
log.Print("Made it this far")
log.Print("Webserver was disabled in the config file")
exit <- true
return
}