1
0
Fork 0
burlesque/main.go

40 lines
493 B
Go
Raw Normal View History

2014-07-08 10:59:16 +00:00
package main
import (
"os"
"os/signal"
"syscall"
)
2014-07-29 06:31:42 +00:00
const (
2014-09-09 08:20:40 +00:00
version = "0.1.3"
2014-07-29 06:31:42 +00:00
)
2014-09-09 08:20:40 +00:00
func handleShutdown() {
2014-07-10 12:19:39 +00:00
ch := make(chan os.Signal)
signal.Notify(ch, os.Interrupt, os.Kill, syscall.SIGTERM, syscall.SIGINT)
2014-07-08 10:59:16 +00:00
go func() {
2014-07-10 12:19:39 +00:00
<-ch
2014-07-12 10:58:56 +00:00
2014-09-09 08:20:40 +00:00
saveState()
log("State successfully persisted")
2014-07-12 10:58:56 +00:00
2014-09-09 08:20:40 +00:00
closeStorage()
2014-07-12 10:58:56 +00:00
2014-09-09 08:20:40 +00:00
log("Stopped")
2014-07-12 10:58:56 +00:00
os.Exit(0)
2014-07-08 10:59:16 +00:00
}()
2014-07-10 12:19:39 +00:00
}
2014-07-08 10:59:16 +00:00
2014-07-10 12:19:39 +00:00
func main() {
2014-09-09 08:20:40 +00:00
setupConfig()
setupLogging()
setupStorage()
setupServer()
handleShutdown()
loadState()
go keepStatePersisted()
startServer()
2014-07-08 10:59:16 +00:00
}