alby-hub/main_wails.go

51 lines
1.2 KiB
Go
Raw Normal View History

//go:build wails
// +build wails
package main
import (
"context"
2024-06-17 19:42:09 +07:00
"embed"
"net"
2024-07-05 20:32:40 +07:00
"github.com/getAlby/hub/logger"
"github.com/getAlby/hub/service"
"github.com/getAlby/hub/wails"
log "github.com/sirupsen/logrus"
)
2024-06-17 19:42:09 +07:00
//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, err := service.NewService(ctx)
if err != nil {
log.WithError(err).Fatal("Failed to create service")
return
}
2024-06-17 19:42:09 +07:00
app := wails.NewApp(svc)
wails.LaunchWailsApp(app, assets, appIcon)
logger.Logger.Info("Wails app exited")
2024-06-17 19:42:09 +07:00
logger.Logger.Info("Cancelling service context...")
// cancel the service context
cancel()
svc.Shutdown()
2024-06-17 19:42:09 +07:00
logger.Logger.Info("Service exited")
logger.Logger.Info("Alby Hub needs to stay online to send and receive transactions. Channels may be closed if your hub stays offline for an extended period of time.")
}