-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmain.go
67 lines (52 loc) · 1.72 KB
/
main.go
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package main
import (
"fmt"
"log"
"os"
"strings"
"time"
"github.com/vacovsky/pirrigo/data"
"github.com/vacovsky/pirrigo/logging"
"github.com/vacovsky/pirrigo/pirri"
)
func main() {
logger := logging.Service()
logger.LogEvent("PirriGo starting up!")
log.Println("PIRRIGO_WEB_PORT:", os.Getenv("PIRRIGO_WEB_PORT"))
log.Println("PIRRIGO_DB_TYPE:", os.Getenv("PIRRIGO_DB_TYPE"))
log.Println("PIRRIGO_DB_PATH:", os.Getenv("PIRRIGO_DB_PATH"))
log.Println("PIRRIGO_SIMULATE_GPIO:", os.Getenv("PIRRIGO_SIMULATE_GPIO"))
log.Println("PIRRIGO_LOG_LOCATION:", os.Getenv("PIRRIGO_LOG_LOCATION"))
log.Println("PIRRIGO_DB_LOGMODE:", os.Getenv("PIRRIGO_DB_LOGMODE"))
log.Println("PIRRIGO_UTC_OFFSET:", os.Getenv("PIRRIGO_UTC_OFFSET"))
log.Println("PIRRIGO_USERNAME:", os.Getenv("PIRRIGO_USERNAME"))
log.Println("PIRRIGO_PASSWORD:", os.Getenv("PIRRIGO_PASSWORD"))
// log.Println("PIRRIGO_ENABLE_AUTH:", os.Getenv("PIRRIGO_ENABLE_AUTH"))
// initialize dependencies
data.Service()
// migrate DB schema and populate with seed data
migrateDataSchema()
// check if we are in local debug mode, or actually doing work.
// If not debug, reset the GPIO state
if strings.ToLower(os.Getenv("PIRRIGO_SIMULATE_GPIO")) != "true" {
pirri.GPIOClear()
}
// set the common wire for powering solenoids
pirri.SetCommonWire()
// init waitgroups for concurrent processing
pirri.WG.Add(3)
// Start the Web application for management of schedule etc.
go pirri.StartPirriWebApp()
// Monitor database for pre-scheduled tasks
go pirri.StartTaskMonitor()
// Listen for tasks to execute
go pirri.ListenForTasks()
go listenForExit()
pirri.WG.Wait()
fmt.Println("Exit key received - exiting!")
}
func listenForExit() {
for {
time.Sleep(1000)
}
}