Detach SSH-spawned workers so remote start returns instead of hanging
Some checks are pending
offline / test (push) Waiting to run
Some checks are pending
offline / test (push) Waiting to run
Remote node is launched in a bash -c background subshell. Live check on NS1: spawn, /health, kill as marchon with ~/.ssh/id_ed25519.
This commit is contained in:
parent
e89e006542
commit
a694f246fb
1 changed files with 3 additions and 1 deletions
|
|
@ -30,6 +30,7 @@ export function sshTarget(machine) {
|
||||||
export function sshBaseArgs(machine) {
|
export function sshBaseArgs(machine) {
|
||||||
const ident = expandHome(machine.identityFile || '');
|
const ident = expandHome(machine.identityFile || '');
|
||||||
const args = [
|
const args = [
|
||||||
|
'-n',
|
||||||
'-o', 'BatchMode=yes',
|
'-o', 'BatchMode=yes',
|
||||||
'-o', 'StrictHostKeyChecking=accept-new',
|
'-o', 'StrictHostKeyChecking=accept-new',
|
||||||
'-o', 'IdentitiesOnly=yes',
|
'-o', 'IdentitiesOnly=yes',
|
||||||
|
|
@ -126,7 +127,8 @@ export async function sshSpawnWorker(machine, { instance, env }) {
|
||||||
.filter(([k]) => k.startsWith('FLEET_'))
|
.filter(([k]) => k.startsWith('FLEET_'))
|
||||||
.map(([k, v]) => `${k}=${shellQuote(v)}`)
|
.map(([k, v]) => `${k}=${shellQuote(v)}`)
|
||||||
.join(' ');
|
.join(' ');
|
||||||
const cmd = `mkdir -p ${remoteDir}/data/${instance} && cd ${remoteDir} && ${fleetEnv} nohup node src/worker.js >data/${instance}/worker.log 2>&1 & echo $!`;
|
const inner = `node src/worker.js </dev/null >data/${instance}/worker.log 2>&1 & echo $!`;
|
||||||
|
const cmd = `mkdir -p ${remoteDir}/data/${instance} && cd ${remoteDir} && ${fleetEnv} bash -c ${shellQuote(inner)}`;
|
||||||
const { stdout } = await sshExec(machine, cmd);
|
const { stdout } = await sshExec(machine, cmd);
|
||||||
const pid = Number(String(stdout).split('\n').pop());
|
const pid = Number(String(stdout).split('\n').pop());
|
||||||
if (!Number.isFinite(pid)) throw new Error(`remote spawn produced no pid: ${stdout}`);
|
if (!Number.isFinite(pid)) throw new Error(`remote spawn produced no pid: ${stdout}`);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue