Spawn a watcher child process for each configured repo.
(self)
| 552 | # ------------------------------------------------------------------ |
| 553 | |
| 554 | def start(self) -> None: |
| 555 | """Spawn a watcher child process for each configured repo.""" |
| 556 | logger.info("Starting daemon '%s'", self._config.session_name) |
| 557 | |
| 558 | # Auto-register repos in the central registry |
| 559 | from .registry import Registry |
| 560 | |
| 561 | registry = Registry() |
| 562 | for repo in self._config.repos: |
| 563 | registry.register(repo.path, alias=repo.alias) |
| 564 | |
| 565 | # Build initial graph for repos that lack a database |
| 566 | for repo in self._config.repos: |
| 567 | db_path = Path(repo.path) / ".code-review-graph" / "graph.db" |
| 568 | if not db_path.exists(): |
| 569 | self._initial_build(repo) |
| 570 | |
| 571 | # Spawn a watcher child for every repo |
| 572 | for repo in self._config.repos: |
| 573 | self._start_watcher(repo) |
| 574 | |
| 575 | # Track current state |
| 576 | self._current_repos = {r.alias: r for r in self._config.repos} |
| 577 | |
| 578 | # Persist child PIDs to disk for cross-process status queries |
| 579 | self._save_state() |
| 580 | |
| 581 | # Start watching the config file for live changes |
| 582 | self.start_config_watcher() |
| 583 | |
| 584 | # Start health checker to auto-restart dead watchers |
| 585 | self.start_health_checker() |
| 586 | |
| 587 | msg = f"Daemon started — watching {len(self._config.repos)} repo(s)" |
| 588 | logger.info(msg) |
| 589 | print(msg) # noqa: T201 |
| 590 | |
| 591 | def stop(self) -> None: |
| 592 | """Tear down the daemon: stop watchers, terminate children.""" |
no test coverage detected