-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
53 lines (38 loc) · 1.02 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
package main
import (
"log"
"net/http"
"runtime"
"github.com/GeertJohan/go.rice"
"github.com/cratonica/trayhost"
"github.com/jangxx/go-poclient"
"github.com/shibukawa/configdir"
)
var config Config
var server *http.Server
var pushover *poclient.Client
var messages map[int]poclient.Message
var pushover_retry = make(chan bool)
func main() {
iconBox := rice.MustFindBox("./icon")
icondata := iconBox.MustBytes("icon_64.png")
runtime.LockOSThread()
go func() {
configDirs := configdir.New("literalchaos", "schubsigo")
config, _ = loadConfig(configDirs, "settings.json")
trayhost.SetUrl("http://" + config.Webserver.Addr + ":" + config.Webserver.Port)
messages = make(map[int]poclient.Message)
pushover = initPOClient(config)
initNotifications()
go listenForMessages(pushover)
go listenForNotifications(pushover)
server = initWebserver(config.Webserver)
}()
trayhost.EnterLoop("SchubsiGo", icondata)
}
func onExit() {
if server != nil {
server.Shutdown(nil)
log.Printf("Server is shutdown")
}
}