blob: dcb201ea11a0d163f556454815cce078be124bd1 (
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
// 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()
}
|