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

Function spawnService

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

Source from the content-addressed store, hash-verified

216let shuttingDown = false;
217
218function spawnService(name, command, args, options = {}) {
219 const proc = spawn(
220 resolveWindowsCommand(command),
221 args,
222 getProcessTreeSpawnOptions({
223 stdio: ["ignore", "pipe", "pipe"],
224 env: { ...process.env, ...options.env },
225 cwd: options.cwd,
226 }),
227 );
228
229 const color = options.color || c.reset;
230
231 proc.stdout.on("data", (data) => {
232 data
233 .toString()
234 .split("\n")
235 .filter(Boolean)
236 .forEach((line) => logService(name, line.trim(), color));
237 });
238
239 proc.stderr.on("data", (data) => {
240 data
241 .toString()
242 .split("\n")
243 .filter(Boolean)
244 .forEach((line) => logService(name, line.trim(), c.yellow));
245 });
246
247 proc.on("error", (error) => {
248 logError(`${name} failed to start: ${error.message}`);
249 });
250
251 proc.on("exit", (code) => {
252 if (code !== 0 && code !== null && !shuttingDown) {
253 logService(name, `Exited with code ${code}`, c.red);
254 }
255 processes.delete(name);
256 });
257
258 processes.set(name, proc);
259 return proc;
260}
261
262async function waitForService(name, url, timeoutMs = 30000) {
263 const start = Date.now();

Callers 5

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

Calls 4

resolveWindowsCommandFunction · 0.90
logServiceFunction · 0.70
logErrorFunction · 0.70

Tested by

no test coverage detected