refactor: drop macOS launchd and nohup service install paths

The service only runs under Linux systemd. Remove setupLaunchd,
setupNohupFallback, buildLaunchdPlist, the launchd/nohup service checks
in setup/verify-services.ts, ServiceDef.launchdLabel, launchd/ and the
unused repo-tokens/ GitHub action. Without systemd, `setup --step
service` now fails with systemd_unavailable instead of writing a nohup
wrapper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Codex
2026-10-01 19:06:09 +09:00
parent a9fe9dac54
commit e999ce9a33
23 changed files with 49 additions and 882 deletions

View File

@@ -1,6 +1,3 @@
import fs from 'fs';
import os from 'os';
import path from 'path';
import { afterEach, describe, expect, it, vi } from 'vitest';
const { execSyncMock, isRootMock } = vi.hoisted(() => ({
@@ -17,10 +14,6 @@ vi.mock('./platform.js', () => ({
}));
import {
checkLaunchdService,
checkLaunchdServiceArtifact,
checkNohupService,
checkNohupServiceArtifact,
checkSystemdService,
checkSystemdServiceInScope,
getServiceChecks,
@@ -35,18 +28,6 @@ describe('verify service checks', () => {
vi.restoreAllMocks();
});
it('treats launchd entries with a PID as running', () => {
execSyncMock.mockReturnValue('123\t0\tcom.ejclaw\n');
expect(checkLaunchdService('com.ejclaw')).toBe('running');
});
it('treats launchd entries without a PID as stopped', () => {
execSyncMock.mockReturnValue('-\t0\tcom.ejclaw\n');
expect(checkLaunchdService('com.ejclaw')).toBe('stopped');
});
it('checks systemd user services with the user prefix', () => {
isRootMock.mockReturnValue(false);
execSyncMock.mockReturnValue(undefined);
@@ -82,25 +63,6 @@ describe('verify service checks', () => {
);
});
it('treats an unloaded launchd plist as stopped when artifact detection is enabled', () => {
const tempHome = fs.mkdtempSync(path.join(os.tmpdir(), 'ejclaw-launchd-'));
const plistPath = path.join(
tempHome,
'Library',
'LaunchAgents',
'com.ejclaw-codex.plist',
);
fs.mkdirSync(path.dirname(plistPath), { recursive: true });
fs.writeFileSync(plistPath, '<plist />');
execSyncMock.mockReturnValue('');
expect(checkLaunchdServiceArtifact('com.ejclaw-codex', plistPath)).toBe(
'stopped',
);
fs.rmSync(tempHome, { recursive: true, force: true });
});
it('treats known but inactive systemd services as stopped', () => {
execSyncMock
.mockImplementationOnce(() => {
@@ -111,55 +73,34 @@ describe('verify service checks', () => {
expect(checkSystemdService('ejclaw')).toBe('stopped');
});
it('treats a live nohup PID as running', () => {
const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'ejclaw-verify-'));
const pidFile = path.join(tempRoot, 'ejclaw.pid');
fs.writeFileSync(pidFile, '12345\n');
const killSpy = vi
.spyOn(process, 'kill')
.mockImplementation((_pid: number, _signal?: string | number) => true);
expect(checkNohupService(tempRoot, 'ejclaw')).toBe('running');
killSpy.mockRestore();
fs.rmSync(tempRoot, { recursive: true, force: true });
});
it('treats a legacy nohup wrapper without a live pid as stopped when artifact detection is enabled', () => {
const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'ejclaw-verify-'));
fs.writeFileSync(
path.join(tempRoot, 'start-ejclaw-codex.sh'),
'#!/bin/bash\n',
);
expect(checkNohupServiceArtifact(tempRoot, 'ejclaw-codex')).toBe('stopped');
fs.rmSync(tempRoot, { recursive: true, force: true });
});
it('builds per-service status checks from service definitions', () => {
const defs: ServiceDef[] = [
{
kind: 'primary',
name: 'ejclaw',
description: 'EJClaw',
launchdLabel: 'com.ejclaw',
logName: 'ejclaw',
},
{
kind: 'primary',
name: 'ejclaw-secondary',
description: 'Secondary',
launchdLabel: 'com.ejclaw.secondary',
logName: 'ejclaw-secondary',
},
];
execSyncMock.mockReturnValue('123\t0\tcom.ejclaw\n');
execSyncMock.mockImplementation((cmd: string) => {
if (cmd === 'systemctl --user is-active ejclaw') return undefined;
if (cmd === 'systemctl --user list-unit-files') return '';
throw new Error('inactive');
});
expect(getServiceChecks(defs, '/tmp/ejclaw', 'launchd')).toEqual([
expect(getServiceChecks(defs, 'systemd')).toEqual([
{ name: 'ejclaw', status: 'running' },
{ name: 'ejclaw-secondary', status: 'not_found' },
]);
expect(getServiceChecks(defs, 'none')).toEqual([
{ name: 'ejclaw', status: 'not_found' },
{ name: 'ejclaw-secondary', status: 'not_found' },
]);
});
});