burlesque/main.go

40 lines
493 B
Go
Raw Normal View History

2014-07-08 17:59:16 +07:00
package main
import (
"os"
"os/signal"
"syscall"
)
2014-07-29 13:31:42 +07:00
const (
Version = "0.1.3"
)
2014-07-10 19:19:39 +07:00
func HandleShutdown() {
ch := make(chan os.Signal)
signal.Notify(ch, os.Interrupt, os.Kill, syscall.SIGTERM, syscall.SIGINT)
2014-07-08 17:59:16 +07:00
go func() {
2014-07-10 19:19:39 +07:00
<-ch
2014-07-12 17:58:56 +07:00
2014-07-08 17:59:16 +07:00
SaveState()
2014-07-12 17:42:26 +07:00
Log("State successfully persisted")
2014-07-12 17:58:56 +07:00
2014-07-17 00:50:05 +07:00
CloseStorage()
2014-07-12 17:58:56 +07:00
Log("Stopped")
os.Exit(0)
2014-07-08 17:59:16 +07:00
}()
2014-07-10 19:19:39 +07:00
}
2014-07-08 17:59:16 +07:00
2014-07-10 19:19:39 +07:00
func main() {
SetupConfig()
2014-07-12 17:58:56 +07:00
SetupLogging()
2014-07-10 19:19:39 +07:00
SetupStorage()
SetupServer()
HandleShutdown()
LoadState()
2014-07-08 17:59:16 +07:00
go KeepStatePersisted()
2014-07-29 13:56:46 +07:00
StartServer()
2014-07-08 17:59:16 +07:00
}