infinicode 2.8.60 → 2.8.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -74,9 +74,11 @@ Wants=network-online.target
|
|
|
74
74
|
Type=simple
|
|
75
75
|
ExecStart=${service.command} ${service.args.map(shellQuote).join(' ')}
|
|
76
76
|
WorkingDirectory=${service.workingDir ?? homedir()}
|
|
77
|
-
Restart=always
|
|
78
|
-
RestartSec=5
|
|
79
|
-
|
|
77
|
+
Restart=always
|
|
78
|
+
RestartSec=5
|
|
79
|
+
KillMode=control-group
|
|
80
|
+
TimeoutStopSec=10
|
|
81
|
+
${envLines}
|
|
80
82
|
|
|
81
83
|
[Install]
|
|
82
84
|
WantedBy=multi-user.target
|
|
@@ -126,6 +126,8 @@ export async function roboparkRobotRuntime(opts) {
|
|
|
126
126
|
const child = spawn(entry.command, entry.args, {
|
|
127
127
|
env: { ...process.env, ...entry.env, ROBOPARK_ROBOT_RUNTIME: '1' },
|
|
128
128
|
stdio: runtimeLog(`robot-${opts.name}-${entry.label}`, foreground),
|
|
129
|
+
// Give each launcher and its Python descendants one process group.
|
|
130
|
+
detached: process.platform !== 'win32',
|
|
129
131
|
});
|
|
130
132
|
entry.child = child;
|
|
131
133
|
child.on('error', error => console.error(chalk.red(` ${entry.label} failed to start: ${error.message}`)));
|
|
@@ -146,23 +148,34 @@ export async function roboparkRobotRuntime(opts) {
|
|
|
146
148
|
start(entry); }, RESTART_DELAY_MS);
|
|
147
149
|
});
|
|
148
150
|
};
|
|
151
|
+
const signalChild = (entry, signal) => {
|
|
152
|
+
const pid = entry.child?.pid;
|
|
153
|
+
if (!pid)
|
|
154
|
+
return;
|
|
155
|
+
try {
|
|
156
|
+
if (process.platform === 'win32')
|
|
157
|
+
entry.child?.kill(signal);
|
|
158
|
+
else
|
|
159
|
+
process.kill(-pid, signal);
|
|
160
|
+
}
|
|
161
|
+
catch {
|
|
162
|
+
// It may have exited between the liveness check and signal.
|
|
163
|
+
}
|
|
164
|
+
};
|
|
149
165
|
const stopChild = async (entry) => {
|
|
150
166
|
const child = entry.child;
|
|
151
167
|
if (!child)
|
|
152
168
|
return;
|
|
153
169
|
await new Promise(resolve => {
|
|
154
|
-
const timer = setTimeout(
|
|
170
|
+
const timer = setTimeout(() => {
|
|
171
|
+
signalChild(entry, 'SIGKILL');
|
|
172
|
+
resolve();
|
|
173
|
+
}, 5_000);
|
|
155
174
|
child.once('exit', () => {
|
|
156
175
|
clearTimeout(timer);
|
|
157
176
|
resolve();
|
|
158
177
|
});
|
|
159
|
-
|
|
160
|
-
child.kill('SIGTERM');
|
|
161
|
-
}
|
|
162
|
-
catch {
|
|
163
|
-
clearTimeout(timer);
|
|
164
|
-
resolve();
|
|
165
|
-
}
|
|
178
|
+
signalChild(entry, 'SIGTERM');
|
|
166
179
|
});
|
|
167
180
|
};
|
|
168
181
|
const recycleAfterMeshUpdate = async () => {
|
|
@@ -217,7 +230,7 @@ export async function roboparkRobotRuntime(opts) {
|
|
|
217
230
|
const shutdown = () => {
|
|
218
231
|
stopping = true;
|
|
219
232
|
for (const entry of [...children, preview])
|
|
220
|
-
entry
|
|
233
|
+
signalChild(entry, 'SIGTERM');
|
|
221
234
|
};
|
|
222
235
|
process.once('SIGINT', shutdown);
|
|
223
236
|
process.once('SIGTERM', shutdown);
|
|
@@ -77,6 +77,24 @@ function stopAllUnix() {
|
|
|
77
77
|
const removedUnits = [];
|
|
78
78
|
const errors = [];
|
|
79
79
|
const self = process.pid;
|
|
80
|
+
if (process.platform === 'linux') {
|
|
81
|
+
// Disable restart policies before killing processes so systemd cannot
|
|
82
|
+
// repopulate the ports between process discovery and cleanup.
|
|
83
|
+
const list = spawnSync('systemctl', ['list-units', '--all', '--plain', '--no-legend'], { encoding: 'utf8' });
|
|
84
|
+
const units = (list.stdout ?? '')
|
|
85
|
+
.split('\n')
|
|
86
|
+
.map(l => l.trim().split(/\s+/)[0])
|
|
87
|
+
.filter((u) => !!u && u.endsWith('.service') && /infinicode|robopark/i.test(u));
|
|
88
|
+
for (const unit of units) {
|
|
89
|
+
const disable = spawnSync('systemctl', ['disable', '--now', unit], { encoding: 'utf8' });
|
|
90
|
+
if (disable.status === 0)
|
|
91
|
+
removedUnits.push(unit);
|
|
92
|
+
else
|
|
93
|
+
errors.push(`systemctl disable --now ${unit}: ${(disable.stderr || '').trim()}`);
|
|
94
|
+
}
|
|
95
|
+
if (units.length)
|
|
96
|
+
spawnSync('systemctl', ['daemon-reload'], { encoding: 'utf8' });
|
|
97
|
+
}
|
|
80
98
|
const ps = spawnSync('ps', ['ax', '-o', 'pid=,command='], { encoding: 'utf8' });
|
|
81
99
|
const lines = (ps.stdout ?? '').split('\n');
|
|
82
100
|
const re = new RegExp(PATTERNS.map(p => p.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('|'));
|
|
@@ -96,7 +114,7 @@ function stopAllUnix() {
|
|
|
96
114
|
}
|
|
97
115
|
// Also free the well-known RoboPark ports directly — belt and suspenders
|
|
98
116
|
// against a supervised process whose command line didn't match a pattern.
|
|
99
|
-
for (const port of [47913, 47921, 47922, 8080, 5000, 5057]) {
|
|
117
|
+
for (const port of [47913, 47921, 47922, 8080, 5000, 5057, 8000]) {
|
|
100
118
|
const lsof = spawnSync('lsof', ['-t', `-i:${port}`], { encoding: 'utf8' });
|
|
101
119
|
const pids = (lsof.stdout ?? '').split('\n').map(s => s.trim()).filter(Boolean).map(Number);
|
|
102
120
|
for (const pid of pids) {
|
|
@@ -112,21 +130,6 @@ function stopAllUnix() {
|
|
|
112
130
|
// include a bare "infinicode.service" (see pi-client install scripts),
|
|
113
131
|
// which a narrower glob would silently leave running (and respawning
|
|
114
132
|
// whatever we just killed, if it has Restart=always).
|
|
115
|
-
const list = spawnSync('systemctl', ['list-units', '--all', '--plain', '--no-legend'], { encoding: 'utf8' });
|
|
116
|
-
const units = (list.stdout ?? '')
|
|
117
|
-
.split('\n')
|
|
118
|
-
.map(l => l.trim().split(/\s+/)[0])
|
|
119
|
-
.filter((u) => !!u && u.endsWith('.service') && /infinicode|robopark/i.test(u));
|
|
120
|
-
for (const unit of units) {
|
|
121
|
-
spawnSync('systemctl', ['stop', unit], { encoding: 'utf8' });
|
|
122
|
-
const disable = spawnSync('systemctl', ['disable', unit], { encoding: 'utf8' });
|
|
123
|
-
if (disable.status === 0)
|
|
124
|
-
removedUnits.push(unit);
|
|
125
|
-
else
|
|
126
|
-
errors.push(`systemctl disable ${unit}: ${(disable.stderr || '').trim()}`);
|
|
127
|
-
}
|
|
128
|
-
if (units.length)
|
|
129
|
-
spawnSync('systemctl', ['daemon-reload'], { encoding: 'utf8' });
|
|
130
133
|
}
|
|
131
134
|
return { killedPids, removedUnits, errors };
|
|
132
135
|
}
|
package/package.json
CHANGED