Revision 66491555
Added by PiBa-NL almost 7 years ago
src/etc/inc/gwlb.inc | ||
---|---|---|
82 | 82 |
} |
83 | 83 |
|
84 | 84 |
if (isvalidpid($process['pidfile'])) { |
85 |
killbypid($process['pidfile']); |
|
85 |
killbypid($process['pidfile'], 3);
|
|
86 | 86 |
} else { |
87 | 87 |
@unlink($process['pidfile']); |
88 | 88 |
} |
src/etc/inc/util.inc | ||
---|---|---|
28 | 28 |
define('VIP_IPALIAS', 3); |
29 | 29 |
|
30 | 30 |
/* kill a process by pid file */ |
31 |
function killbypid($pidfile) { |
|
32 |
return sigkillbypid($pidfile, "TERM"); |
|
31 |
function killbypid($pidfile, $waitfor = 0) {
|
|
32 |
return sigkillbypid($pidfile, "TERM", $waitfor);
|
|
33 | 33 |
} |
34 | 34 |
|
35 | 35 |
function isvalidpid($pidfile) { |
... | ... | |
52 | 52 |
return is_process_running($proc); |
53 | 53 |
} |
54 | 54 |
|
55 |
/* sigkill a process by pid file */ |
|
55 |
/* sigkill a process by pid file, and wait for it to terminate or remove the .pid file for $waitfor seconds */
|
|
56 | 56 |
/* return 1 for success and 0 for a failure */ |
57 |
function sigkillbypid($pidfile, $sig) { |
|
57 |
function sigkillbypid($pidfile, $sig, $waitfor = 0) {
|
|
58 | 58 |
if (isvalidpid($pidfile)) { |
59 |
return mwexec("/bin/pkill " . escapeshellarg("-{$sig}") .
|
|
59 |
$result = mwexec("/bin/pkill " . escapeshellarg("-{$sig}") .
|
|
60 | 60 |
" -F {$pidfile}", true); |
61 |
$waitcounter = $waitfor * 10; |
|
62 |
while(isvalidpid($pidfile) && $waitcounter > 0) { |
|
63 |
$waitcounter = $waitcounter - 1; |
|
64 |
usleep(100000); |
|
65 |
} |
|
66 |
return $result; |
|
61 | 67 |
} |
62 | 68 |
|
63 | 69 |
return 0; |
Also available in: Unified diff
gateway monitoring, wait for apinger to terminate or remove its pid file when restarting it.