8000 Archive /var/run/snabb/PID directory in case of crash by dpino · Pull Request #1378 · snabbco/snabb · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Archive /var/run/snabb/PID directory in case of crash #1378

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/core/main.lua
8000
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,40 @@ function initialize ()
_G.main = getfenv()
end

local function archive (src)
local function isdir (path)
local stat = S.stat(path)
return stat.isdir
end
local function copy (src, dst)
for _, each in ipairs(S.util.dirtable(src, true)) do
if isdir(src..'/'..each) then
local src, dst = src..'/'..each, dst..'/'..each
S.mkdir(dst, tonumber(755, 8))
copy(src, dst)
else
local src, dst = src..'/'..each, dst..'/'..each
S.util.touch(dst)
S.util.cp(src, dst)
end
end
end
src = src or shm.root..'/'..S.getpid()
assert(isdir(src))
local dst = shm.root..'/crash'
if not S.stat(dst) then
S.mkdir(dst, tonumber(755, 8))
end
dst = dst..'/'..lib.basename(src)
S.mkdir(dst, tonumber(755, 8))
copy(src, dst)
end

function handler (reason)
print(reason)
print(STP.stacktrace())
if debug_on_error then debug.debug() end
archive()
os.exit(1)
end

Expand Down
0