mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-29 22:55:06 +03:00
Reorder code
This commit is contained in:
parent
7b437a1dcd
commit
17b775b4b9
1 changed files with 26 additions and 26 deletions
|
@ -43,6 +43,32 @@ type node struct {
|
|||
admin *admin.AdminSocket
|
||||
}
|
||||
|
||||
func main() {
|
||||
var cmdLineEnv CmdLineEnv
|
||||
cmdLineEnv.parseFlagsAndArgs()
|
||||
|
||||
hup := make(chan os.Signal, 1)
|
||||
//signal.Notify(hup, os.Interrupt, syscall.SIGHUP)
|
||||
term := make(chan os.Signal, 1)
|
||||
signal.Notify(term, os.Interrupt, syscall.SIGTERM)
|
||||
for {
|
||||
done := make(chan struct{})
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
go run(cmdLineEnv, ctx, done)
|
||||
select {
|
||||
case <-hup:
|
||||
cancel()
|
||||
<-done
|
||||
case <-term:
|
||||
cancel()
|
||||
<-done
|
||||
return
|
||||
case <-done:
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func readConfig(log *log.Logger, useconf bool, useconffile string, normaliseconf bool) *config.NodeConfig {
|
||||
// Use a configuration file. If -useconf, the configuration will be read
|
||||
// from stdin. If -useconffile, the configuration will be read from the
|
||||
|
@ -340,29 +366,3 @@ func (n *node) shutdown() {
|
|||
_ = n.tuntap.Stop()
|
||||
n.core.Stop()
|
||||
}
|
||||
|
||||
func main() {
|
||||
var cmdLineEnv CmdLineEnv
|
||||
cmdLineEnv.parseFlagsAndArgs()
|
||||
|
||||
hup := make(chan os.Signal, 1)
|
||||
//signal.Notify(hup, os.Interrupt, syscall.SIGHUP)
|
||||
term := make(chan os.Signal, 1)
|
||||
signal.Notify(term, os.Interrupt, syscall.SIGTERM)
|
||||
for {
|
||||
done := make(chan struct{})
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
go run(cmdLineEnv, ctx, done)
|
||||
select {
|
||||
case <-hup:
|
||||
cancel()
|
||||
<-done
|
||||
case <-term:
|
||||
cancel()
|
||||
<-done
|
||||
return
|
||||
case <-done:
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue