MCPcopy Create free account
hub / github.com/cocoindex-io/cocoindex-code / start_daemon

Function start_daemon

src/cocoindex_code/client.py:414–448  ·  view source on GitHub ↗

Start the daemon as a background process. Returns the ``Popen`` object so callers can detect early process death (via ``proc.poll()``) instead of waiting for a full timeout.

()

Source from the content-addressed store, hash-verified

412
413
414def start_daemon() -> subprocess.Popen[bytes]:
415 """Start the daemon as a background process.
416
417 Returns the ``Popen`` object so callers can detect early process death
418 (via ``proc.poll()``) instead of waiting for a full timeout.
419 """
420 daemon_runtime_dir().mkdir(parents=True, exist_ok=True)
421 log_path = daemon_log_path()
422
423 ccc_path = _find_ccc_executable()
424 if ccc_path:
425 cmd = [ccc_path, "run-daemon"]
426 else:
427 cmd = [sys.executable, "-m", "cocoindex_code.cli", "run-daemon"]
428
429 log_fd = open(log_path, "w")
430 if sys.platform == "win32":
431 _create_no_window = 0x08000000
432 proc = subprocess.Popen(
433 cmd,
434 stdout=log_fd,
435 stderr=log_fd,
436 stdin=subprocess.DEVNULL,
437 creationflags=_create_no_window,
438 )
439 else:
440 proc = subprocess.Popen(
441 cmd,
442 start_new_session=True,
443 stdout=log_fd,
444 stderr=log_fd,
445 stdin=subprocess.DEVNULL,
446 )
447 log_fd.close()
448 return proc
449
450
451def _find_ccc_executable() -> str | None:

Callers 4

e2e_daemonFunction · 0.90
_connect_and_handshakeFunction · 0.85
daemon_restartFunction · 0.85

Calls 4

daemon_runtime_dirFunction · 0.85
daemon_log_pathFunction · 0.85
_find_ccc_executableFunction · 0.85
closeMethod · 0.80