-
Notifications
You must be signed in to change notification settings - Fork 357
/
main.go
32 lines (29 loc) · 885 Bytes
/
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
package main
import (
"github.com/kingparks/cursor-vip/auth"
"github.com/kingparks/cursor-vip/tui"
"github.com/kingparks/cursor-vip/tui/params"
"github.com/kingparks/cursor-vip/tui/shortcut"
"github.com/kingparks/cursor-vip/tui/tool"
"os"
"os/signal"
"syscall"
)
func main() {
productSelected, modelIndexSelected := tui.Run()
startServer(productSelected, modelIndexSelected)
}
func startServer(productSelected string, modelIndexSelected int) {
lock, pidFilePath, _ := tool.EnsureSingleInstance("cursor-vip")
params.Sigs = make(chan os.Signal, 1)
signal.Notify(params.Sigs, os.Interrupt, syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGKILL)
go func() {
<-params.Sigs
_ = lock.Unlock()
_ = os.Remove(pidFilePath)
auth.UnSetClient(productSelected)
os.Exit(0)
}()
go shortcut.Do()
auth.Run(productSelected, modelIndexSelected)
}