-
Notifications
You must be signed in to change notification settings - Fork 7
/
main.go
50 lines (42 loc) · 1.17 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
// Package main is where Lominus starts from.
package main
import (
"github.com/beebeeoii/lominus/internal/app"
appLock "github.com/beebeeoii/lominus/internal/app/lock"
"github.com/beebeeoii/lominus/internal/cron"
logs "github.com/beebeeoii/lominus/internal/log"
"github.com/beebeeoii/lominus/internal/notifications"
"github.com/beebeeoii/lominus/internal/ui"
"github.com/juju/fslock"
)
// Main is the starting point of where magic begins.
func main() {
db, appInitErr := app.Init()
if appInitErr != nil {
logs.Logger.Fatalln(appInitErr)
}
logs.Logger.Infoln("app initialised")
defer db.Close()
lockPath, getLockPathErr := appLock.GetLockPath()
if getLockPathErr != nil {
logs.Logger.Fatalln(getLockPathErr)
}
lock := fslock.New(lockPath)
lockErr := lock.TryLock()
if lockErr != nil {
logs.Logger.Fatalln(lockErr)
}
defer lock.Unlock()
logs.Logger.Infoln("lock initialised")
notifications.Init()
logs.Logger.Infoln("notifications initialised")
cronInitErr := cron.Init()
if cronInitErr != nil {
logs.Logger.Fatalln(cronInitErr)
}
logs.Logger.Infoln("cron initialised")
uiInitErr := ui.Init()
if uiInitErr != nil {
logs.Logger.Fatalln(uiInitErr)
}
}