mirror of
https://github.com/getAlby/hub.git
synced 2026-08-13 12:33:39 +02:00
fix: prevent user starting wails app twice
This commit is contained in:
parent
ff417c4f1e
commit
22d721d1e4
1 changed files with 9 additions and 0 deletions
|
|
@ -6,6 +6,7 @@ package main
|
|||
import (
|
||||
"context"
|
||||
"embed"
|
||||
"net"
|
||||
|
||||
"github.com/getAlby/hub/logger"
|
||||
"github.com/getAlby/hub/service"
|
||||
|
|
@ -20,6 +21,14 @@ var assets embed.FS
|
|||
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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue