-
Notifications
You must be signed in to change notification settings - Fork 20
/
main_wails.go
45 lines (36 loc) · 968 Bytes
/
main_wails.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
//go:build wails
// +build wails
package main
import (
"context"
"embed"
"net"
"github.com/getAlby/hub/logger"
"github.com/getAlby/hub/service"
"github.com/getAlby/hub/wails"
log "github.com/sirupsen/logrus"
)
//go:embed all:frontend/dist
var assets embed.FS
//go:embed appicon.png
var appIcon []byte
func main() {
// Get a port lock on a rare port to prevent the app running twice
listener, err := net.Listen("tcp", "0.0.0.0:21420")
if err != nil {
log.Println("Another instance of Alby Hub is already running.")
return
}
defer listener.Close()
log.Info("Alby Hub starting in WAILS mode")
ctx, cancel := context.WithCancel(context.Background())
svc, _ := service.NewService(ctx)
app := wails.NewApp(svc)
wails.LaunchWailsApp(app, assets, appIcon)
logger.Logger.Info("Wails app exited")
logger.Logger.Info("Cancelling service context...")
// cancel the service context
cancel()
svc.Shutdown()
logger.Logger.Info("Service exited")
}