MCPcopy Create free account
hub / github.com/OpenHands/OpenHands / spawnService

Function spawnService

scripts/dev-static.mjs:245–287  ·  view source on GitHub ↗
(name, command, args, options = {})

Source from the content-addressed store, hash-verified

243let shuttingDown = false;
244
245function spawnService(name, command, args, options = {}) {
246 const proc = spawn(
247 resolveWindowsCommand(command),
248 args,
249 getProcessTreeSpawnOptions({
250 stdio: ["ignore", "pipe", "pipe"],
251 env: { ...process.env, ...options.env },
252 cwd: options.cwd,
253 }),
254 );
255
256 const color = options.color || c.reset;
257
258 proc.stdout.on("data", (data) => {
259 data
260 .toString()
261 .split("\n")
262 .filter(Boolean)
263 .forEach((line) => logService(name, line.trim(), color));
264 });
265
266 proc.stderr.on("data", (data) => {
267 data
268 .toString()
269 .split("\n")
270 .filter(Boolean)
271 .forEach((line) => logService(name, line.trim(), c.yellow));
272 });
273
274 proc.on("error", (error) => {
275 logError(`${name} failed to start: ${error.message}`);
276 });
277
278 proc.on("exit", (code) => {
279 if (code !== 0 && code !== null && !shuttingDown) {
280 logService(name, `Exited with code ${code}`, c.red);
281 }
282 processes.delete(name);
283 });
284
285 processes.set(name, proc);
286 return proc;
287}
288
289async function waitForService(name, url, timeoutMs = 30000) {
290 const start = Date.now();

Callers 5

startAgentServerFunction · 0.70
startAutomationBackendFunction · 0.70
startStaticServerFunction · 0.70
startIngressFunction · 0.70

Calls 7

resolveWindowsCommandFunction · 0.90
deleteMethod · 0.80
setMethod · 0.80
spawnFunction · 0.70
logServiceFunction · 0.70
logErrorFunction · 0.70

Tested by

no test coverage detected