Systemd Service

Run Mudabbir as a background service on Linux with systemd for automatic startup and restart.

Service File

Create /etc/systemd/system/mudabbir.service:

[Unit]
Description=Mudabbir AI Agent
After=network.target
[Service]
Type=simple
User=mudabbir
Group=mudabbir
WorkingDirectory=/home/mudabbir
ExecStart=/usr/local/bin/mudabbir
Restart=on-failure
RestartSec=10
# Environment
EnvironmentFile=/etc/mudabbir/env
# Security hardening
NoNewPrivileges=yes
ProtectSystem=strict
ProtectHome=read-only
ReadWritePaths=/home/mudabbir/.mudabbir
PrivateTmp=yes
[Install]
WantedBy=multi-user.target

Environment File

Create /etc/mudabbir/env:

Terminal window
MUDABBIR_ANTHROPIC_API_KEY=sk-ant-your-key
MUDABBIR_WEB_HOST=127.0.0.1
MUDABBIR_WEB_PORT=8888
MUDABBIR_AGENT_BACKEND=claude_agent_sdk
MUDABBIR_TOOL_PROFILE=coding

Set permissions:

Terminal window
sudo chmod 600 /etc/mudabbir/env
sudo chown mudabbir:mudabbir /etc/mudabbir/env

Setup

Terminal window
# Create dedicated user
sudo useradd -m -s /bin/bash mudabbir
# Install Mudabbir
sudo -u mudabbir pip install --user mudabbir[recommended]
# Create config directory
sudo mkdir -p /etc/mudabbir
sudo chown mudabbir:mudabbir /etc/mudabbir
# Enable and start service
sudo systemctl daemon-reload
sudo systemctl enable mudabbir
sudo systemctl start mudabbir

Managing the Service

Terminal window
# Start
sudo systemctl start mudabbir
# Stop
sudo systemctl stop mudabbir
# Restart
sudo systemctl restart mudabbir
# Check status
sudo systemctl status mudabbir
# View logs
sudo journalctl -u mudabbir -f
# View recent logs
sudo journalctl -u mudabbir --since "1 hour ago"

Log Rotation

Systemd handles log rotation via journald. For the audit log, add a logrotate config:

/home/mudabbir/.mudabbir/audit.jsonl {
weekly
rotate 12
compress
missingok
notifempty
copytruncate
}

Auto-Updates

Create a timer for periodic updates:

/etc/systemd/system/mudabbir-update.timer
[Unit]
Description=Update Mudabbir weekly
[Timer]
OnCalendar=weekly
Persistent=true
[Install]
WantedBy=timers.target
/etc/systemd/system/mudabbir-update.service
[Unit]
Description=Update Mudabbir
[Service]
Type=oneshot
User=mudabbir
ExecStart=/usr/local/bin/pip install --upgrade mudabbir[recommended]
ExecStartPost=/bin/systemctl restart mudabbir