Fix job hangs on invalid/missing commands (#1187)
Original motivation: > Not all systems have a `python` executable in their path. In this situation, sync will never complete with the message: "installing hererocks...". This fix will log the situation and callback with an error code. Additionally helps in cases where `git` or commands passed via `run` are missing.
This commit is contained in:
parent
ef50f6fe40
commit
b134cba054
|
@ -50,7 +50,7 @@ end
|
|||
local spawn = a.wrap(function(cmd, options, callback)
|
||||
local handle = nil
|
||||
local timer = nil
|
||||
handle = loop.spawn(cmd, options, function(exit_code, signal)
|
||||
handle, pid = loop.spawn(cmd, options, function(exit_code, signal)
|
||||
handle:close()
|
||||
if timer ~= nil then
|
||||
timer:stop()
|
||||
|
@ -78,6 +78,13 @@ local spawn = a.wrap(function(cmd, options, callback)
|
|||
end
|
||||
end
|
||||
|
||||
if handle == nil then
|
||||
-- pid is an error string in this case
|
||||
log.error(string.format("Failed spawning command: %s because %s", cmd, pid))
|
||||
callback(-1, pid)
|
||||
return
|
||||
end
|
||||
|
||||
if options.timeout then
|
||||
timer = loop.new_timer()
|
||||
timer:start(options.timeout, 0, function()
|
||||
|
|
Loading…
Reference in New Issue