BUGFIX: Always able to collect status code

This commit is contained in:
Jeroen De Meerleer 2021-05-28 11:45:30 +02:00
parent fda747c143
commit f9d78ef009
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6
2 changed files with 9 additions and 3 deletions

View File

@ -70,6 +70,7 @@ class DaemonCommand extends Command
sleep(1); sleep(1);
} }
$output->writeln('Ended after ' . $timelimit . ' seconds'); $output->writeln('Ended after ' . $timelimit . ' seconds');
pcntl_wait($status);
return Command::SUCCESS; return Command::SUCCESS;
} }
} }

View File

@ -112,10 +112,15 @@ class Job extends Repository
} }
if (!$ssh->login($user, $key)) { if (!$ssh->login($user, $key)) {
throw new \Exception('Login failed'); $return['output'] = "Login failed";
$return['exitcode'] = 255;
return $return;
} }
$return['output'] = $ssh->exec($command); $command .= ';echo "[return_code:$?]"';
$return['exitcode'] = $ssh->getExitStatus(); $output = $ssh->exec($command);
preg_match( '/\[return_code:(.*?)\]/', $output, $match );
$return['output'] = str_replace($match[0] . "\n", '', $output);
$return['exitcode'] = $match[1];
return $return; return $return;
} }