Removed check for pgrep. IsProcessUP replaced by GetProcessPIDs.
This commit is contained in:
parent
4837a8b66e
commit
8dac26b2bb
19
main.go
19
main.go
@ -6,7 +6,6 @@ import (
|
|||||||
. "httpprocwatchd/prog"
|
. "httpprocwatchd/prog"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"syscall"
|
"syscall"
|
||||||
)
|
)
|
||||||
@ -58,10 +57,6 @@ func main() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := exec.LookPath("pgrep"); err != nil {
|
|
||||||
log.Fatalln(ErrPgrepNotFound)
|
|
||||||
}
|
|
||||||
|
|
||||||
conf, err := LoadConfiguration(oConfigPath)
|
conf, err := LoadConfiguration(oConfigPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Cannot load configuration file: %s\n", err)
|
log.Fatalf("Cannot load configuration file: %s\n", err)
|
||||||
@ -89,16 +84,16 @@ func main() {
|
|||||||
// If we modified a list then let's look for a running program and
|
// If we modified a list then let's look for a running program and
|
||||||
// send SIGHUP for it to reload a list.
|
// send SIGHUP for it to reload a list.
|
||||||
if oAddProcess != "" || oRemoveProcess != "" {
|
if oAddProcess != "" || oRemoveProcess != "" {
|
||||||
isup, pid, _ := IsProcessUp("httpprocwatchd")
|
pids, _ := GetProcessPIDs("httpprocwatchd")
|
||||||
if isup && pid != nil && len(pid) > 1 {
|
if pids != nil && len(pids) > 1 {
|
||||||
var trgt_pid int
|
var trgt_pid int
|
||||||
if pid[0] == os.Getpid() {
|
if pids[0] == os.Getpid() {
|
||||||
trgt_pid = pid[1]
|
trgt_pid = pids[1]
|
||||||
} else {
|
} else {
|
||||||
trgt_pid = pid[0]
|
trgt_pid = pids[0]
|
||||||
}
|
}
|
||||||
proc, err := os.FindProcess(trgt_pid)
|
|
||||||
if err == nil {
|
if proc, err := os.FindProcess(trgt_pid); err == nil {
|
||||||
proc.Signal(syscall.SIGHUP)
|
proc.Signal(syscall.SIGHUP)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user