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 (
2014-09-09 12:20:40 +04:00
version = "0.1.3"
2014-07-29 13:31:42 +07:00
)
2014-09-09 12:20:40 +04:00
func handleShutdown() {
2014-07-10 19:19:39 +07:00
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-09-09 12:20:40 +04:00
saveState()
log("State successfully persisted")
2014-07-12 17:58:56 +07:00
2014-09-09 12:20:40 +04:00
closeStorage()
2014-07-12 17:58:56 +07:00
2014-09-09 12:20:40 +04:00
log("Stopped")
2014-07-12 17:58:56 +07:00
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() {
2014-09-09 12:20:40 +04:00
setupConfig()
setupLogging()
setupStorage()
setupServer()
handleShutdown()
loadState()
go keepStatePersisted()
startServer()
2014-07-08 17:59:16 +07:00
}