mirror of
https://github.com/wyx2685/V2bX.git
synced 2026-02-04 04:30:08 +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
|
||||
|
||||
@@ -2,19 +2,20 @@ package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
version = "TempVersion" //use ldflags replace
|
||||
codename = "V2bX"
|
||||
intro = "A V2board backend based on Xray-core"
|
||||
intro = "A V2board backend based on multi core"
|
||||
)
|
||||
|
||||
var versionCommand = cobra.Command{
|
||||
Use: "version",
|
||||
Short: "Print version info",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
Run: func(_ *cobra.Command, _ []string) {
|
||||
showVersion()
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user