Files
cursor-vip/main.go
kingparks@jeter.eu.org 348e17133b cursor-vip update
2024-12-21 12:14:24 +08:00

33 lines
885 B
Go

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)
}