Initial upload: API Mock CLI v0.1.0
Some checks failed
CI / test (3.10) (push) Has been cancelled
CI / test (3.11) (push) Has been cancelled
CI / test (3.12) (push) Has been cancelled
CI / test (3.9) (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / type-check (push) Has been cancelled
CI / build (push) Has been cancelled
Some checks failed
CI / test (3.10) (push) Has been cancelled
CI / test (3.11) (push) Has been cancelled
CI / test (3.12) (push) Has been cancelled
CI / test (3.9) (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / type-check (push) Has been cancelled
CI / build (push) Has been cancelled
This commit is contained in:
24
src/cli/commands/stop.py
Normal file
24
src/cli/commands/stop.py
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
import os
|
||||||
|
import click
|
||||||
|
|
||||||
|
|
||||||
|
@click.command("stop")
|
||||||
|
def stop_command():
|
||||||
|
pid_file = "api-mock.pid"
|
||||||
|
if os.path.exists(pid_file):
|
||||||
|
try:
|
||||||
|
with open(pid_file, "r") as f:
|
||||||
|
pid = int(f.read().strip())
|
||||||
|
os.kill(pid, 15)
|
||||||
|
os.remove(pid_file)
|
||||||
|
click.echo(f"Server stopped (PID: {pid})")
|
||||||
|
except ProcessLookupError:
|
||||||
|
click.echo("Server process not found, cleaning up stale PID file")
|
||||||
|
os.remove(pid_file)
|
||||||
|
except PermissionError:
|
||||||
|
click.echo("Permission denied to stop server")
|
||||||
|
except Exception as e:
|
||||||
|
click.echo(f"Error stopping server: {e}")
|
||||||
|
else:
|
||||||
|
click.echo("No running server found (no PID file)")
|
||||||
|
click.echo("If a server is running, you may need to kill it manually")
|
||||||
Reference in New Issue
Block a user