Major architectural refactoring to separate server and UI concerns: Architecture Changes: - Split into anvilsrv (server daemon) and Assist (Acme client) - Removed UI coupling from server (OnAliasChange, WinID tracking) - Server runs as background daemon, client reconnects as needed - Client auto-starts server if not running Server (anvilsrv): - Add daemon management: start/stop/status commands - Daemonize by default (fgstart for foreground/debug mode) - Proper PID file handling in $NAMESPACE (not /tmp) - Graceful shutdown with SIGTERM handling - Duplicate start prevention with stale PID detection Client (Assist): - Auto-start anvilsrv if not running - Fixed plan9 package imports (OWRITE/OREAD constants) - Removed unused context import Security Fixes: - Move PID file from /tmp to $NAMESPACE (prevent symlink attacks) - Add path validation in session creation: - Clean path traversal (/../../../etc → /etc) - Verify directory exists before creating session - Ensure absolute paths - Reject non-directory paths - Add SECURITY.md documenting 9P socket risks Service Integration: - Add systemd service files (system, user, template) - Add runit service files (run, finish) - Add service documentation and installation instructions Build & Testing: - Both binaries build successfully - All daemon operations verified (start/stop/status/daemonize) - Path validation tested and working - Auto-start functionality verified - Add DevReviewQA workflow script 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| README.md | ||
| anvilsrv-user.service | ||
| anvilsrv.service | ||
| anvilsrv@.service | ||
README.md
systemd Service Units for anvilsrv
This directory contains systemd service unit files for running anvilsrv as a system service.
Service Files
1. anvilsrv-user.service - User Service (Recommended)
Run anvilsrv as a user service using systemd's user instance.
Installation:
# Copy the service file
mkdir -p ~/.config/systemd/user
cp services/systemd/anvilsrv-user.service ~/.config/systemd/user/
# Reload systemd user daemon
systemctl --user daemon-reload
# Enable and start the service
systemctl --user enable anvilsrv-user.service
systemctl --user start anvilsrv-user.service
# Check status
systemctl --user status anvilsrv-user.service
Management:
- Start:
systemctl --user start anvilsrv-user - Stop:
systemctl --user stop anvilsrv-user - Restart:
systemctl --user restart anvilsrv-user - Status:
systemctl --user status anvilsrv-user - Logs:
journalctl --user -u anvilsrv-user -f - Disable:
systemctl --user disable anvilsrv-user
Enable Linger (Start on Boot):
To make the service start on system boot even when not logged in:
sudo loginctl enable-linger $USER
2. anvilsrv@.service - System Service Template
Run anvilsrv as a system service for specific users.
Installation:
# Copy the service file
sudo cp services/systemd/anvilsrv@.service /etc/systemd/system/
# Reload systemd daemon
sudo systemctl daemon-reload
# Enable and start for a specific user (replace 'username')
sudo systemctl enable anvilsrv@username.service
sudo systemctl start anvilsrv@username.service
# Check status
sudo systemctl status anvilsrv@username.service
Management:
- Start:
sudo systemctl start anvilsrv@username - Stop:
sudo systemctl stop anvilsrv@username - Restart:
sudo systemctl restart anvilsrv@username - Status:
sudo systemctl status anvilsrv@username - Logs:
sudo journalctl -u anvilsrv@username -f - Disable:
sudo systemctl disable anvilsrv@username
3. anvilsrv.service - Simple System Service
Basic system service (less flexible than the template).
Installation:
# Edit the service file to set the correct username
nano services/systemd/anvilsrv.service
# Copy the service file
sudo cp services/systemd/anvilsrv.service /etc/systemd/system/
# Reload systemd daemon
sudo systemctl daemon-reload
# Enable and start the service
sudo systemctl enable anvilsrv.service
sudo systemctl start anvilsrv.service
# Check status
sudo systemctl status anvilsrv.service
Choosing the Right Service
- User Service (
anvilsrv-user.service): Best for most users. Runs in your user session, easier to manage, no sudo required. - System Service Template (
anvilsrv@.service): Good for multi-user systems or when you need system-level control. - Simple System Service (
anvilsrv.service): Basic system service, less flexible.
Troubleshooting
Check Logs
# User service
journalctl --user -u anvilsrv-user -n 50
# System service
sudo journalctl -u anvilsrv@username -n 50
Verify Service is Running
# User service
systemctl --user status anvilsrv-user
# System service
sudo systemctl status anvilsrv@username
Check if anvilsrv is Actually Running
anvilsrv status
Restart After Code Changes
# User service
systemctl --user restart anvilsrv-user
# System service
sudo systemctl restart anvilsrv@username
Notes
- The service automatically restarts on failure with a 5-second delay
- PID file is cleaned up on service stop
- Logs are available via journalctl
- The service uses the anvilsrv binary from
~/bin/anvilsrv