export class StopDaemonUseCase {
    deps;
    constructor(deps) {
        this.deps = deps;
    }
    execute(input) {
        const pidContent = this.deps.readPidFile();
        if (!pidContent) {
            return { status: 'not-running' };
        }
        if (!this.deps.isProcessRunning(pidContent.pid)) {
            this.deps.removePidFile();
            return { status: 'not-running' };
        }
        const signal = input.force ? 'SIGKILL' : 'SIGTERM';
        try {
            this.deps.killProcess(pidContent.pid, signal);
        }
        catch (error) {
            const message = error instanceof Error ? error.message : String(error);
            return { status: 'failed', reason: message };
        }
        this.deps.removePidFile();
        return { status: 'stopped', pid: pidContent.pid };
    }
}
//# sourceMappingURL=stopDaemon.usecase.js.map