blob: c1e0571968b5918111d3dce29536992ddf520df4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
package main
import (
"log"
"os"
"os/signal"
"database/sql"
"syscall"
)
var config RuntimeConfig
var db *sql.DB
func main() {
log.Printf("Started Ceres recipe server.\n")
config = GetRuntimeConfig()
db = setupDatabase()
provideShutdown()
runServer()
}
func provideShutdown() {
var listener = make(chan os.Signal)
signal.Notify(listener, syscall.SIGTERM)
signal.Notify(listener, syscall.SIGINT)
go func() {
signal := <-listener
log.Printf("Got signal '%+v'. Shutdown is started.\n", signal)
dbCleanup(db)
os.Exit(0)
}()
}
|