mirror of
https://github.com/wyx2685/V2bX.git
synced 2026-02-04 12:40:11 +00:00
update
add conditional compilation support add multi core support
This commit is contained in:
@@ -1,16 +1,18 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/Yuzuki616/V2bX/conf"
|
||||
"github.com/Yuzuki616/V2bX/core"
|
||||
"github.com/Yuzuki616/V2bX/limiter"
|
||||
"github.com/Yuzuki616/V2bX/node"
|
||||
"github.com/spf13/cobra"
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
"runtime"
|
||||
"syscall"
|
||||
|
||||
vCore "github.com/Yuzuki616/V2bX/core"
|
||||
|
||||
"github.com/Yuzuki616/V2bX/conf"
|
||||
"github.com/Yuzuki616/V2bX/limiter"
|
||||
"github.com/Yuzuki616/V2bX/node"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -44,14 +46,17 @@ func serverHandle(_ *cobra.Command, _ []string) {
|
||||
}
|
||||
limiter.Init()
|
||||
log.Println("Start V2bX...")
|
||||
x := core.New(c)
|
||||
err = x.Start()
|
||||
vc, err := vCore.NewCore(&c.CoreConfig)
|
||||
if err != nil {
|
||||
log.Fatalf("Start xray-core error: %s", err)
|
||||
log.Fatalf("New core error: %s", err)
|
||||
}
|
||||
defer x.Close()
|
||||
err = vc.Start()
|
||||
if err != nil {
|
||||
log.Fatalf("Start core error: %s", err)
|
||||
}
|
||||
defer vc.Close()
|
||||
nodes := node.New()
|
||||
err = nodes.Start(c.NodesConfig, x)
|
||||
err = nodes.Start(c.NodesConfig, vc)
|
||||
if err != nil {
|
||||
log.Fatalf("Run nodes error: %s", err)
|
||||
return
|
||||
@@ -59,18 +64,26 @@ func serverHandle(_ *cobra.Command, _ []string) {
|
||||
if watch {
|
||||
err = c.Watch(config, func() {
|
||||
nodes.Close()
|
||||
err = x.Restart(c)
|
||||
err = vc.Close()
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to restart xray-core: %s", err)
|
||||
}
|
||||
err = nodes.Start(c.NodesConfig, x)
|
||||
vc, err = vCore.NewCore(&c.CoreConfig)
|
||||
if err != nil {
|
||||
log.Fatalf("run nodes error: %s", err)
|
||||
log.Fatalf("New core error: %s", err)
|
||||
}
|
||||
err = vc.Start()
|
||||
if err != nil {
|
||||
log.Fatalf("Start core error: %s", err)
|
||||
}
|
||||
err = nodes.Start(c.NodesConfig, vc)
|
||||
if err != nil {
|
||||
log.Fatalf("Run nodes error: %s", err)
|
||||
}
|
||||
runtime.GC()
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatalf("watch config file error: %s", err)
|
||||
log.Fatalf("Watch config file error: %s", err)
|
||||
}
|
||||
}
|
||||
// clear memory
|
||||
|
||||
Reference in New Issue
Block a user