mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-03 22:45:13 +08:00
增加stop命令
This commit is contained in:
22
node/node.go
22
node/node.go
@@ -12,7 +12,6 @@ import (
|
||||
"os/signal"
|
||||
"strconv"
|
||||
"syscall"
|
||||
"time"
|
||||
)
|
||||
|
||||
var closeSig chan bool
|
||||
@@ -97,27 +96,34 @@ func Start() {
|
||||
}
|
||||
|
||||
|
||||
func stopNode(processid interface{}){
|
||||
func stopNode(arg interface{}) error {
|
||||
processid,err := getRunProcessPid()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
KillProcess(processid)
|
||||
return nil
|
||||
}
|
||||
|
||||
func startNode(paramNodeId interface{}) {
|
||||
func startNode(paramNodeId interface{}) error {
|
||||
initNode(paramNodeId.(int))
|
||||
cluster.GetCluster().Start()
|
||||
service.Start()
|
||||
writeProcessPid()
|
||||
for {
|
||||
bRun := true
|
||||
|
||||
for bRun {
|
||||
select {
|
||||
case <-sigs:
|
||||
fmt.Printf("Recv stop sig")
|
||||
break
|
||||
default:
|
||||
time.Sleep(time.Second)
|
||||
log.Debug("receipt stop signal.")
|
||||
bRun = false
|
||||
}
|
||||
}
|
||||
|
||||
close(closeSig)
|
||||
service.WaitStop()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
|
||||
17
node/node_linux.go
Normal file
17
node/node_linux.go
Normal file
@@ -0,0 +1,17 @@
|
||||
// +build linux
|
||||
|
||||
package node
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func KillProcess(processId int){
|
||||
err := syscall.Kill(processId,syscall.Signal(10))
|
||||
if err != nil {
|
||||
fmt.Printf("kill processid %d is fail:%+v.\n",processId,err)
|
||||
}else{
|
||||
fmt.Printf("kill processid %d is successful.\n",processId)
|
||||
}
|
||||
}
|
||||
1
node/node_other.go
Normal file
1
node/node_other.go
Normal file
@@ -0,0 +1 @@
|
||||
package node
|
||||
Reference in New Issue
Block a user