restart capability
This commit is contained in:
parent
115a7b6ddc
commit
8b63561bef
3 changed files with 24 additions and 5 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -78,4 +78,5 @@ dkms.conf
|
|||
|
||||
### USER MODIFIED ###
|
||||
c-daemon/bin/
|
||||
go-daemon/bin/
|
||||
go-daemon/bin/
|
||||
go-daemon/local-ref.sh
|
|
@ -28,11 +28,8 @@ func main() {
|
|||
|
||||
log.Print("- - - - - - - - - - - - - - -")
|
||||
log.Print("daemon started")
|
||||
log.Print(d, err)
|
||||
// process, err := os.FindProcess(1)
|
||||
// daemon.SendCommands(process)
|
||||
|
||||
for true {
|
||||
for {
|
||||
Info()
|
||||
time.Sleep(10 * time.Second)
|
||||
}
|
||||
|
|
21
go-daemon/service/restart.go
Normal file
21
go-daemon/service/restart.go
Normal file
|
@ -0,0 +1,21 @@
|
|||
package service
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func Restart() error {
|
||||
log.Println("Restart Signal Caught")
|
||||
|
||||
// TODO what you want to do before restarting daemon?
|
||||
|
||||
self, err := os.Executable()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
args := os.Args
|
||||
env := os.Environ()
|
||||
return syscall.Exec(self, args, env)
|
||||
}
|
Loading…
Reference in a new issue