summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-04-16 20:44:26 +0800
committerruki <[email protected]>2022-04-16 20:44:26 +0800
commitc50be9dc24299bdd05fc024dd726b5199a2f6f7d (patch)
treefcfc3cc03e200ed0b3c191c984ed0b31c09903cf
parent838e53f354b121da72c3fc51efd1e44f876adfa1 (diff)
improve to start server
-rw-r--r--xmake/modules/private/service/start_service.lua18
1 files changed, 17 insertions, 1 deletions
diff --git a/xmake/modules/private/service/start_service.lua b/xmake/modules/private/service/start_service.lua
index f9dd357df..d24ec242a 100644
--- a/xmake/modules/private/service/start_service.lua
+++ b/xmake/modules/private/service/start_service.lua
@@ -49,7 +49,23 @@ function main(opt)
os.mkdir(logdir)
end
end
- os.execv(os.programfile(), argv, {detach = true, stdout = logfile, stderr = logfile})
+ local tmpdir = os.tmpfile() .. ".dir"
+ if not os.isdir(tmpdir) then
+ os.mkdir(tmpdir)
+ end
+ try
+ {
+ function()
+ os.execv(os.programfile(), argv, {detach = true, curdir = tmpdir, stdout = logfile, stderr = logfile})
+ end,
+ catch
+ {
+ function (errors)
+ io.cat(logfile)
+ raise(errors)
+ end
+ }
+ }
else
service()
end