Go utility to restart (via exec) a program when a new version is written to disk
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
LICENSE
README.md
autorestart.go
zombie_cleanup.go

README.md

autorestart

GoDoc

Go library to restart (via exec) a program when a new version is written to disk.

Basic usage

To restart daemons in conjunction with autoinstall, call RestartOnChange during initialization, e.g.:

import "github.com/tillberg/autorestart"
func main() {
    go autorestart.RestartOnChange()
    ...
}

This restarts the daemon by calling syscall.Exec, which is not portable and is unsupported on Windows. Exec replaces the current process with the new one, maintaining the same PID as before and such. This a super-convenient way to restart processes, but it can be a bit different than what you might expect when being restarted by a parent process; you might want to read about it a little first: linux.die.net wikipedia

Specifically, if your daemon accumulates zombie subprocesses over restarts, the CleanUpChildZombies function might help.

See documentation for additional details.