MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / startInfra

Function startInfra

dev/local/runner.ts:398–430  ·  view source on GitHub ↗
(repoRoot: string, serviceNames: string[])

Source from the content-addressed store, hash-verified

396 const ESCALATE_AT_MS = 15_000; // second SIGINT for shutdowns stuck on children
397 const GIVE_UP_AT_MS = 60_000;
398 // Two consecutive idle polls, not one: a service on its way out can briefly
399 // have a shell as its last living descendant, and typing then would feed the
400 // keystrokes to a process that still owns the tty.
401 const IDLE_POLLS_BEFORE_RELAUNCH = 2;
402 return new Promise<RestartOutcome>(resolve => {
403 let elapsed = 0;
404 let escalated = false;
405 let idlePolls = 0;
406 const settle = (outcome: RestartOutcome) => {
407 clearInterval(timer);
408 if (inFlightRestarts.get(restartKey) === cancel) inFlightRestarts.delete(restartKey);
409 resolve(outcome);
410 };
411 const cancel = () => settle('superseded');
412 inFlightRestarts.set(restartKey, cancel);
413 const timer = setInterval(() => {
414 elapsed += POLL_MS;
415 const currentPane = findServicePane(sessionName, serviceName);
416 if (!currentPane) {
417 // The pane can close together with the process (SIGINT kills the
418 // non-interactive wrapper shell before its `exec $SHELL` runs, and
419 // tmux closes a pane when its process exits). Recreate the service
420 // window instead of leaving the service stopped after reporting
421 // "Restarted"; the new window inherits the tmux session environment.
422 try {
423 startServiceInTmux(sessionName, serviceName, env, serviceNames);
424 settle('recreated');
425 } catch {
426 // Same policy as below: keep the TUI alive; the next explicit
427 // restart/view action can retry.
428 settle('gave-up');
429 }
430 return;
431 }
432 // Shell children do not count: ctrl-c, send-keys and dashboard clicks
433 // leave extra login shells parented to the pane shell, and waiting on

Callers 1

cmdUpFunction · 0.90

Calls 6

getServiceFunction · 0.90
getInfraProfileFunction · 0.90
waitForPortFunction · 0.85
addMethod · 0.80
joinMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected