-
Notifications
You must be signed in to change notification settings - Fork 1
Pipeline Plan 16
Let me write the plan to a non-sensitive location and present it directly.
Here is the implementation plan:
Refactor sw-launchd.sh to detect the OS at runtime and generate either macOS launchd plist files or Linux systemd unit files accordingly. Add a new test suite to validate unit file generation on both platforms.
| File | Action | Purpose |
|---|---|---|
scripts/sw-launchd.sh |
Modify | Add OS detection, systemd unit generation, systemd status/uninstall |
scripts/sw-launchd-test.sh |
Create | Test suite for service file generation on both platforms |
package.json |
Modify | Register sw-launchd-test.sh in the test script |
.github/workflows/test.yml |
Modify | Add sw-launchd-test.sh step |
Add to the constants section (after the existing launchd paths):
# Linux systemd paths (user units) SYSTEMD_DIR="$HOME/.config/systemd/user" DAEMON_UNIT="$SYSTEMD_DIR/shipwright-daemon.service" DASHBOARD_UNIT="$SYSTEMD_DIR/shipwright-dashboard.service" CONNECT_UNIT="$SYSTEMD_DIR/shipwright-connect.service"
Rename existing cmd_install -> cmd_install_launchd, cmd_uninstall -> cmd_uninstall_launchd, cmd_status -> cmd_status_launchd. Remove the check_macos() calls inside them (the dispatcher handles it).
Generate three systemd user service units. Key properties:
-
Type=simple,Restart=on-failure,RestartSec=10 -
KillSignal=SIGTERM,TimeoutStopSec=30(daemon) /15(dashboard, connect) -
StandardOutput=journal+SyslogIdentifier=shipwright-*(log rotation via journald) WantedBy=default.target- Connect service:
After=shipwright-daemon.service, only generated if$TEAM_CONFIGexists
After writing files: systemctl --user daemon-reload, then systemctl --user enable --now each service.
systemctl --user disable --now each service, remove unit files, systemctl --user daemon-reload.
systemctl --user is-active each service with colored indicators. Show recent journal lines via journalctl --user -u shipwright-daemon -n 3 --no-pager.
cmd_install() { if is_macos; then cmd_install_launchd elif is_linux; then cmd_install_systemd else error "Unsupported platform"; exit 1; fi }
Same pattern for cmd_uninstall and cmd_status.
Change header from "Process supervision on macOS" to "Process supervision (macOS launchd / Linux systemd)". Update the install/status/uninstall descriptions to reflect cross-platform support.
Mock strategy: Override _COMPAT_UNAME env var to control is_macos/is_linux from compat.sh. Create mock systemctl/launchctl in $TEMP_DIR/bin prepended to PATH.
Tests:
- OS detection routes to systemd on Linux
- Systemd unit content (
ExecStart,WorkingDirectory,KillSignal=SIGTERM,Restart=on-failure) - Systemd unit permissions (644)
- Connect service only generated when
$TEAM_CONFIGexists - macOS plist generation with mocked
launchctl - Plist content (
KeepAlive,RunAtLoad,ProgramArguments) - Uninstall systemd removes unit files
- Uninstall launchd removes plist files
- Status systemd — mock
systemctl, verify colored output - Status launchd — mock
launchctl, verify colored output - Unsupported OS exits with error
- SIGTERM + TimeoutStopSec present in systemd units
-
StandardOutput=journalin all systemd units
Add && bash scripts/sw-launchd-test.sh to package.json test script. Add step in .github/workflows/test.yml.
- Task 1: Add systemd path constants to
sw-launchd.sh - Task 2: Extract macOS install logic into
cmd_install_launchd - Task 3: Implement
cmd_install_systemdwith 3 unit files - Task 4: Extract macOS uninstall logic into
cmd_uninstall_launchd - Task 5: Implement
cmd_uninstall_systemd - Task 6: Extract macOS status logic into
cmd_status_launchd - Task 7: Implement
cmd_status_systemd - Task 8: Add OS-dispatch wrappers for install/uninstall/status
- Task 9: Update help text and script header
- Task 10: Create
sw-launchd-test.shwith 13 test cases - Task 11: Register test in
package.jsonandtest.yml - Task 12: Run tests locally, fix failures
- Task 13: Sync docs
-
Unit tests (
sw-launchd-test.sh): Mock_COMPAT_UNAME,systemctl,launchctlin temp dir. Verify file content, permissions, conditionals, error paths. -
CI matrix: Already runs on
[macos-latest, ubuntu-latest]— the new suite exercises the native codepath on each runner. -
Manual: On Linux,
shipwright launchd installand verify withsystemctl --user list-units.
-
shipwright launchd installdetects OS and generates appropriate service files - systemd unit files for daemon, dashboard, connect
-
shipwright launchd statusworks on both macOS and Linux - Graceful shutdown via
KillSignal=SIGTERM+TimeoutStopSec - Log rotation via journald (
StandardOutput=journal) - macOS behavior unchanged
- 13-test suite passes on macOS and Ubuntu CI
- No Bash 3.2 compatibility violations