-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
44 lines (36 loc) · 1.22 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
package main
import (
"flag"
"os"
"github.com/coma-toast/notifapi/internal/utils"
"github.com/coma-toast/notifapi/pkg/api"
"github.com/coma-toast/notifapi/pkg/app"
"github.com/coma-toast/notifapi/pkg/discord_notifier" // Add this import statement
)
func main() {
app := app.App{}
configPath := flag.String("conf", ".", "Path for the config file.")
flag.Parse()
app.Config = *utils.GetConf(*configPath)
app.Logger.Init(false, app.Config.LogFilePath+"notifapi.log")
app.Logger.Info("App initialized")
app.Data.Init(app.Config.DBFilePath)
hostname, err := os.Hostname()
if err != nil {
app.Logger.Error(err)
}
// app.Notifier = pusher.Pusher{InstanceID: app.Config.InstanceID, SecretKey: app.Config.SecretKey, Data: &app.Data}
app.Notifier = discord_notifier.NewDiscordNotifier(app.Config.DiscordWebhookURL)
// * re-enable when back online
id, err := app.Notifier.SendMessage([]string{"hello"}, "NotifAPI", "NotifAPI is starting up on "+hostname, "main.go")
if err != nil {
app.Logger.ErrorWithField("Error sending message", "interest", "hello")
}
// id := hostname
app.Logger.Debug(id)
api := api.API{App: &app}
go api.RunAPI()
dontExit := make(chan bool)
// Waiting for a channel that never comes...
<-dontExit
}