Expirementing with building everthing from scratch.
1st steps
This commit is contained in:
@@ -1,48 +1,4 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"log"
|
||||
"time"
|
||||
)
|
||||
|
||||
var quitChan chan string = make(chan string)
|
||||
|
||||
func main() {
|
||||
mongoStr := flag.String("mongo", "", "MongoDB connection string for APIs")
|
||||
flag.Parse()
|
||||
go linker()
|
||||
go webserver(*mongoStr)
|
||||
go startSMTPServer()
|
||||
for failure := <-quitChan; ; failure = <-quitChan {
|
||||
switch failure {
|
||||
case "tcp conf":
|
||||
continue
|
||||
case "tcp err":
|
||||
go tcpLinkerRestart()
|
||||
case "web arg":
|
||||
continue
|
||||
case "web err":
|
||||
go websiteRestart(*mongoStr)
|
||||
case "smtp arg":
|
||||
continue
|
||||
case "smtp err":
|
||||
//TODO: restart smtp server
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func tcpLinkerRestart() {
|
||||
log.Println("TCP linker failed. Restarting in 5 seconds...")
|
||||
time.Sleep(5 * time.Second)
|
||||
log.Println("Restarting tcp linker")
|
||||
linker()
|
||||
}
|
||||
|
||||
func websiteRestart(mongoStr string) {
|
||||
log.Println("Website failed. Restarting in 5 seconds...")
|
||||
time.Sleep(5 * time.Second)
|
||||
log.Println("Restarting website")
|
||||
webserver(mongoStr)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user