Simplify restart func

This commit is contained in:
Alex X
2024-04-29 10:41:53 +03:00
parent c7af5028be
commit cf4f6468f3
2 changed files with 9 additions and 21 deletions

View File

@@ -2,9 +2,7 @@ package shell
import (
"os"
"os/exec"
"os/signal"
"path/filepath"
"regexp"
"strings"
"syscall"
@@ -70,20 +68,3 @@ func RunUntilSignal() {
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
println("exit with signal:", (<-sigs).String())
}
// Restart idea taken from https://github.com/tillberg/autorestart
// Copyright (c) 2015, Dan Tillberg
func Restart() {
path, err := exec.LookPath(os.Args[0])
if err != nil {
return
}
path, err = filepath.Abs(path)
if err != nil {
return
}
path = filepath.Clean(path)
if err = syscall.Exec(path, os.Args, os.Environ()); err != nil {
panic(err)
}
}