This document explains how to install and run the Agent Manager as a systemd service.
claude)The easiest way to install the systemd service is using the automated installation script:
cd /home/claude/agent-manager
./install.sh
The script will automatically:
To uninstall the service:
./uninstall.sh
If you prefer to install manually:
Clone the repository to the user's home directory:
cd /home/claude
git clone <repository-url> agent-manager
cd agent-manager
Create your .env file from the example:
cp .env.example .env
Edit .env to configure your settings:
nano .env
Create your commands.json from the example:
cp commands.json.example commands.json
Edit commands.json to configure your webhook commands:
nano commands.json
Copy the service file to systemd directory (requires sudo):
sudo cp agent-manager.service /etc/systemd/system/
If your installation path is different from /home/claude/agent-manager, edit the service file:
sudo nano /etc/systemd/system/agent-manager.service
Update these fields:
WorkingDirectory: Path to your installationUser: The unprivileged user to run asGroup: The group to run asReadWritePaths: Path to your installation (for writing queue.json)Reload systemd to recognize the new service:
sudo systemctl daemon-reload
Enable the service to start on boot:
sudo systemctl enable agent-manager
Start the service:
sudo systemctl start agent-manager
sudo systemctl status agent-manager
journalctl -u agent-manager -f -n100
journalctl -u agent-manager -n100
journalctl -u agent-manager --since "2025-10-28 10:00:00"
journalctl -u agent-manager --since today
sudo systemctl stop agent-manager
sudo systemctl restart agent-manager
sudo systemctl disable agent-manager
When updating the application code:
Stop the service:
sudo systemctl stop agent-manager
Pull the latest changes:
cd /home/claude/agent-manager
git pull
Start the service:
sudo systemctl start agent-manager
Check logs to ensure it started correctly:
journalctl -u agent-manager -f -n50
The logger automatically detects when running under systemd and adjusts its output:
You can view logs using journalctl:
# Follow logs in real-time
journalctl -u agent-manager -f
# Show last 100 lines
journalctl -u agent-manager -n100
# Show logs from the last hour
journalctl -u agent-manager --since "1 hour ago"
# Show logs with specific priority (error, warning, info)
journalctl -u agent-manager -p err
# Export logs to file
journalctl -u agent-manager > agent-manager.log
The service file includes several security hardening options:
NoNewPrivileges=true: Prevents privilege escalationPrivateTmp=true: Uses private /tmp directoryProtectSystem=strict: Makes most of the filesystem read-onlyProtectHome=read-only: Makes home directories read-only (except WorkingDirectory)ReadWritePaths: Only allows writing to the application directoryCheck the service status:
sudo systemctl status agent-manager
View detailed logs:
journalctl -u agent-manager -n100
Ensure the claude user has read/write access to the application directory:
sudo chown -R claude:claude /home/claude/agent-manager
Check if another process is using port 3000 (or your configured port):
sudo lsof -i :3000
Either stop the conflicting process or change the port in .env:
PORT=3001
Then restart the service:
sudo systemctl restart agent-manager
Ensure Node.js is installed and the path in the service file is correct:
which node
If the path is different, update ExecStart in /etc/systemd/system/agent-manager.service.
The application needs write access to create queue.json for job persistence. Ensure:
# Check ownership
ls -la /home/claude/agent-manager
# Fix ownership if needed
sudo chown -R claude:claude /home/claude/agent-manager
# Verify permissions
ls -la /home/claude/agent-manager/queue.json
Add environment variables in the service file under the [Service] section:
Environment=NODE_ENV=production
Environment=CUSTOM_VAR=value
Or use an environment file:
EnvironmentFile=/home/claude/agent-manager/.env.systemd
The service is configured to restart on failure with a 10-second delay. Modify these settings in the service file:
Restart=on-failure
RestartSec=10s
Options for Restart:
no: Never restarton-failure: Restart only on failureon-abnormal: Restart on abnormal terminationalways: Always restartAdd resource limits to the service file:
[Service]
MemoryMax=500M
CPUQuota=50%
TasksMax=100