-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "refactor(cmd): use resty.signal for process signaling (#11382)"
This reverts commit bbdda0b.
- Loading branch information
1 parent
bbdda0b
commit 2c26014
Showing
14 changed files
with
134 additions
and
727 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
local pl_path = require "pl.path" | ||
local pl_utils = require "pl.utils" | ||
local log = require "kong.cmd.utils.log" | ||
|
||
local cmd_tmpl = [[kill %s `cat %s 2>&1` >/dev/null 2>&1]] | ||
|
||
local function kill(pid_file, args) | ||
log.debug("sending signal to pid at: %s", pid_file) | ||
local cmd = string.format(cmd_tmpl, args or "-0", pid_file) | ||
if pl_path.exists(pid_file) then | ||
log.debug(cmd) | ||
local _, code = pl_utils.execute(cmd) | ||
return code | ||
else | ||
log.debug("no pid file at: %s", pid_file) | ||
return 0 | ||
end | ||
end | ||
|
||
local function is_running(pid_file) | ||
-- we do our own pid_file exists check here because | ||
-- we want to return `nil` in case of NOT running, | ||
-- and not `0` like `kill` would return. | ||
if pl_path.exists(pid_file) then | ||
return kill(pid_file) == 0 | ||
end | ||
end | ||
|
||
return { | ||
kill = kill, | ||
is_running = is_running | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.