// vim: shiftwidth=4 tabstop=4 noexpandtab package main import ( "log" "os" "os/signal" "syscall" ) var ( config RuntimeConfig camera Camera ipc IpcServer ) const ( IPC_SOCKET = "/tmp/birdscan.sock" // FIXME ) func main() { // disable log timestamp because systemd takes care of that log.SetFlags(0) // parse flags and read config config = GetRuntimeConfig() // create services camera = NewCamera() // main service ipc = NewIpcServer() // inter process communication web := NewWebServer() // web frontend // allow graceful exit 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'", signal) ipc.Cleanup() os.Exit(0) }() // start secondary services go ipc.Run(IPC_SOCKET) go PicameraSubprocess(IPC_SOCKET) // subprocess to use Python picamera go web.run() // start main service camera.run() }