summaryrefslogtreecommitdiff
path: root/src/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.go')
-rw-r--r--src/main.go25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/main.go b/src/main.go
index dfcf706..af82e8f 100644
--- a/src/main.go
+++ b/src/main.go
@@ -5,25 +5,40 @@ package main
import (
"flag"
"log"
- "time"
"os"
"io/ioutil"
"encoding/json"
)
+var (
+ camera Machine
+)
+
type config struct {
WebConfig webConfig `json:"webserver"`
}
func main() {
+
+ // read command line arguments
configPath := readFlags()
+
+ // set up log and print startup message
log.SetFlags(0) // disable timestamp because systemd takes care of that
log.Println("Starting birdscan")
+
+ // read config file
cfg := readConfig(configPath)
- go runServer(&cfg.WebConfig)
- for {
- time.Sleep(1 * time.Second)
- }
+
+ // setup camera state machine
+ camera = newCamStateMachine()
+
+ // start goroutines
+ server := NewWebServer(&cfg.WebConfig)
+ go server.run() // http server
+
+ // run camera state machine
+ camera.run()
}
func readFlags() string {