restart.go raw
1 //go:build linux
2
3 package interrupt
4
5 import (
6 "next.orly.dev/pkg/lol/log"
7 "os"
8 "syscall"
9
10 "github.com/kardianos/osext"
11 )
12
13 // Restart uses syscall.Exec to restart the process. macOS and Windows are not
14 // implemented, currently.
15 func Restart() {
16 log.D.Ln("restarting")
17 file, e := osext.Executable()
18 if e != nil {
19 log.E.Ln(e)
20 return
21 }
22 e = syscall.Exec(file, os.Args, os.Environ())
23 if e != nil {
24 log.F.Ln(e)
25 }
26 }
27