mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-17 23:33:12 +09:00
Exit run scripts with the code that stopped the restart loop (#1212)
run-controller.sh and run-host.sh ran `exit $?` after the `[[ ]]` test, so they exited with the test's status (0) even when the process exited with 8 to ask not to be restarted. Save the status before testing it. The .cmd scripts now pass 8 to `exit /b` explicitly instead of relying on a bare `exit /b` to carry the errorlevel through. Closes #1208. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
154ebe294a
commit
ec2bc6504b
2 files changed
+20
-4
No files matched your search
@@ -446,7 +446,7 @@ set "NODE_OPTIONS=--enable-source-maps %NODE_OPTIONS%"
|
||||
:restart
|
||||
call .\\node_modules\\.bin\\clusteriocontroller.cmd run --can-restart
|
||||
if %errorlevel% equ 0 exit /b
|
||||
if %errorlevel% equ 8 exit /b
|
||||
if %errorlevel% equ 8 exit /b 8
|
||||
goto restart
|
||||
`
|
||||
);
|
||||
@@ -458,7 +458,8 @@ goto restart
|
||||
export "NODE_OPTIONS=--enable-source-maps $NODE_OPTIONS"
|
||||
while true; do
|
||||
./node_modules/.bin/clusteriocontroller run --can-restart
|
||||
if [[ $? -eq 0 || $? -eq 8 ]]; then exit $?; fi
|
||||
code=$?
|
||||
if [[ $code -eq 0 || $code -eq 8 ]]; then exit $code; fi
|
||||
done
|
||||
`,
|
||||
{ mode: 0o755 },
|
||||
@@ -498,7 +499,7 @@ set "NODE_OPTIONS=--enable-source-maps %NODE_OPTIONS%"
|
||||
${extraCaCertsLine}:restart
|
||||
call .\\node_modules\\.bin\\clusteriohost.cmd run --can-restart
|
||||
if %errorlevel% equ 0 exit /b
|
||||
if %errorlevel% equ 8 exit /b
|
||||
if %errorlevel% equ 8 exit /b 8
|
||||
goto restart
|
||||
`
|
||||
);
|
||||
@@ -511,7 +512,8 @@ goto restart
|
||||
export "NODE_OPTIONS=--enable-source-maps $NODE_OPTIONS"
|
||||
${extraCaCertsLine}while true; do
|
||||
./node_modules/.bin/clusteriohost run --can-restart
|
||||
if [[ $? -eq 0 || $? -eq 8 ]]; then exit $?; fi
|
||||
code=$?
|
||||
if [[ $code -eq 0 || $code -eq 8 ]]; then exit $code; fi
|
||||
done
|
||||
`,
|
||||
{ mode: 0o755 },
|
||||
|
||||
@@ -195,6 +195,20 @@ describe("create installer CLI", function() {
|
||||
await fs.access(path.join(directory, `run-host${process.platform === "win32" ? ".cmd" : ".sh"}`));
|
||||
});
|
||||
|
||||
it("writes a run script that exits with the code that stopped the restart loop", async function() {
|
||||
if (process.platform === "win32") {
|
||||
this.skip();
|
||||
}
|
||||
await run(hostArgs());
|
||||
const binDir = path.join(directory, "node_modules", ".bin");
|
||||
await fs.mkdir(binDir, { recursive: true });
|
||||
await fs.writeFile(path.join(binDir, "clusteriohost"), "#!/bin/sh\nexit 8\n", { mode: 0o755 });
|
||||
await assert.rejects(
|
||||
execFileAsync(path.join(directory, "run-host.sh"), [], { cwd: directory }),
|
||||
{ code: 8 },
|
||||
);
|
||||
});
|
||||
|
||||
it("adds the trailing slash the host requires to the controller URL", async function() {
|
||||
await run(hostArgs(controllerUrl.slice(0, -1)));
|
||||
assert((await commands()).includes(hostSet("host.controller_url", controllerUrl)));
|
||||
|
||||
Reference in new issue
Block a user