new: make tunnel service working

This commit is contained in:
Hiddify
2024-02-02 13:47:41 +01:00
parent ad764a86b1
commit 7bdfee5459
14 changed files with 232 additions and 94 deletions

View File

@@ -1,6 +1,8 @@
package main
import (
"fmt"
"github.com/hiddify/libcore/admin_service"
"github.com/spf13/cobra"
@@ -11,9 +13,12 @@ var commandService = &cobra.Command{
Short: "Sign box service start/stop/install/uninstall",
Args: cobra.MaximumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
if len(args) < 2 {
admin_service.StartService("")
arg := ""
if len(args) > 1 {
arg = args[1]
}
admin_service.StartService(args[1])
code, out := admin_service.StartService(arg)
fmt.Printf("exitCode:%d msg=%s", code, out)
},
}

View File

@@ -2,7 +2,9 @@ package main
import (
"fmt"
"time"
"os"
"os/signal"
"syscall"
"github.com/hiddify/libcore/config"
"github.com/hiddify/libcore/global"
@@ -53,6 +55,11 @@ func runSingbox(configPath string) error {
}
go global.StartServiceC(false, configStr)
fmt.Printf("Waiting for 30 seconds\n")
<-time.After(time.Second * 30)
// <-time.After(time.Second * 30)
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM)
<-sigChan
return err
}