diff --git a/.gitignore b/.gitignore index 67a015d..bd09563 100644 --- a/.gitignore +++ b/.gitignore @@ -78,4 +78,5 @@ dkms.conf ### USER MODIFIED ### c-daemon/bin/ -go-daemon/bin/ \ No newline at end of file +go-daemon/bin/ +go-daemon/local-ref.sh \ No newline at end of file diff --git a/go-daemon/godaemon1.go b/go-daemon/godaemon1.go index 03468fa..99432a7 100644 --- a/go-daemon/godaemon1.go +++ b/go-daemon/godaemon1.go @@ -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) } diff --git a/go-daemon/service/restart.go b/go-daemon/service/restart.go new file mode 100644 index 0000000..2458616 --- /dev/null +++ b/go-daemon/service/restart.go @@ -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) +}