From 80fef728b42337a3682ba09bdb30f6cb9ffb8931 Mon Sep 17 00:00:00 2001 From: Bradley Schofield Date: Wed, 11 Aug 2021 14:23:37 +0100 Subject: [PATCH] Implement UNIX Exit Code suggestion --- app/workers/functions.php | 8 ++++---- composer.lock | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/workers/functions.php b/app/workers/functions.php index 950fd7735d..1a499c2d19 100644 --- a/app/workers/functions.php +++ b/app/workers/functions.php @@ -440,7 +440,7 @@ class FunctionsV1 extends Worker $exitCode = 0; try { - $exitCode = $orchestration->execute( + $exitCode = (int)!$orchestration->execute( name: $container, command: $orchestration->parseCommandString($command), stdout: $stdout, @@ -448,12 +448,12 @@ class FunctionsV1 extends Worker vars: $vars, timeout: $function->getAttribute('timeout', (int) App::getEnv('_APP_FUNCTIONS_TIMEOUT', 900))); } catch (TimeoutException $e) { - $exitCode = 0; + $exitCode = 124; } $executionEnd = \microtime(true); $executionTime = ($executionEnd - $executionStart); - $functionStatus = $exitCode ? 'completed' : 'failed'; + $functionStatus = ($exitCode === 0) ? 'completed' : 'failed'; Console::info('Function executed in ' . ($executionEnd - $executionStart) . ' seconds, status: ' . $functionStatus); @@ -462,7 +462,7 @@ class FunctionsV1 extends Worker $execution = $database->updateDocument(array_merge($execution->getArrayCopy(), [ 'tagId' => $tag->getId(), 'status' => $functionStatus, - 'exitCode' => ($exitCode ? 0 : 1), + 'exitCode' => ($exitCode === 0 ? 0 : 1), 'stdout' => \mb_substr($stdout, -4000), // log last 4000 chars output 'stderr' => \mb_substr($stderr, -4000), // log last 4000 chars output 'time' => $executionTime diff --git a/composer.lock b/composer.lock index 802355eb25..0105c0348c 100644 --- a/composer.lock +++ b/composer.lock @@ -1913,12 +1913,12 @@ "source": { "type": "git", "url": "https://github.com/PineappleIOnic/orchestration.git", - "reference": "d19c498731807aaadf583c58356011c8f39c53cf" + "reference": "213d8796cd3b4a23b8d3728227b0e8ab1ceb4aea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PineappleIOnic/orchestration/zipball/d19c498731807aaadf583c58356011c8f39c53cf", - "reference": "d19c498731807aaadf583c58356011c8f39c53cf", + "url": "https://api.github.com/repos/PineappleIOnic/orchestration/zipball/213d8796cd3b4a23b8d3728227b0e8ab1ceb4aea", + "reference": "213d8796cd3b4a23b8d3728227b0e8ab1ceb4aea", "shasum": "" }, "require": { @@ -1963,7 +1963,7 @@ "support": { "source": "https://github.com/PineappleIOnic/orchestration/tree/dev" }, - "time": "2021-08-11T10:38:19+00:00" + "time": "2021-08-11T12:45:16+00:00" }, { "name": "utopia-php/preloader",