gobserve

command module
v0.1.0-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2021 License: Unlicense Imports: 9 Imported by: 0

README

Goverwatch

Actions Status codecov

Golang file watcher

Specify a command to execute and a list of files to watch on.
If one of the file is modified, your command will be re-executed.
It is useful in a development environment to have hot reloading.

echo "trigger watcher" > test.txt
go run main.go -c "go build main.go" -files test.txt
go run goverwatch.go -c "go run test/server.go" -files "*/*.go"

Processes

cmd.Start() will create a child process.
If you use the Kill() function it will kill this process but not his childrens.
His childrens will then be sons of INIT (PID 1) which can lead to unwanted scenarios.
To prevent that we are using process group in order to kill process and all of his childrens.

To kill this process and his childrens we have to add them in the same process group.

cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}

We can then kill every process in the group by passing a negative integer to the Kill() function.

syscall.Kill(-runningProcess.Pid, syscall.SIGKILL)

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL