mirror of
https://github.com/wyx2685/V2bX.git
synced 2025-02-02 06:48:14 -05:00
add watch config option
This commit is contained in:
parent
baab76d667
commit
72936370e7
3
main.go
3
main.go
@ -15,6 +15,7 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
configFile = flag.String("config", "/etc/V2bX/config.yml", "Config file for V2bX.")
|
configFile = flag.String("config", "/etc/V2bX/config.yml", "Config file for V2bX.")
|
||||||
|
watch = flag.Bool("watch", true, "Watch config file for changes.")
|
||||||
printVersion = flag.Bool("version", false, "show version")
|
printVersion = flag.Bool("version", false, "show version")
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -51,6 +52,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Panicf("run nodes error: %s", err)
|
log.Panicf("run nodes error: %s", err)
|
||||||
}
|
}
|
||||||
|
if *watch {
|
||||||
err = config.Watch(*configFile, func() {
|
err = config.Watch(*configFile, func() {
|
||||||
nodes.Close()
|
nodes.Close()
|
||||||
err = x.Restart(config)
|
err = x.Restart(config)
|
||||||
@ -66,6 +68,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Panicf("watch config file error: %s", err)
|
log.Panicf("watch config file error: %s", err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
//Explicitly triggering GC to remove garbage from config loading.
|
//Explicitly triggering GC to remove garbage from config loading.
|
||||||
runtime.GC()
|
runtime.GC()
|
||||||
// Running backend
|
// Running backend
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
// Package node the InbounderConfig used by add inbound
|
|
||||||
package controller
|
package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
Loading…
Reference in New Issue
Block a user