| 598 | |
| 599 | |
| 600 | def _handle_lingering_services(kill: bool = False) -> None: |
| 601 | uid = os.getuid() |
| 602 | for proc in psutil.process_iter(): |
| 603 | try: |
| 604 | if proc.name() in REQUIRED_SERVICES: |
| 605 | if proc.uids().real != uid: |
| 606 | print( |
| 607 | f"Ignoring {proc.name()} process with different UID (PID {proc.pid}, likely running in Docker)" |
| 608 | ) |
| 609 | elif kill: |
| 610 | print(f"Killing orphaned {proc.name()} process (PID {proc.pid})") |
| 611 | proc.kill() |
| 612 | else: |
| 613 | ui.warn( |
| 614 | f"Existing {proc.name()} process (PID {proc.pid}) will be reused" |
| 615 | ) |
| 616 | except psutil.NoSuchProcess: |
| 617 | continue |
| 618 | |
| 619 | |
| 620 | if __name__ == "__main__": |