Service Management¶
Complete guide to managing Mailborder services using SystemD.
Overview¶
Mailborder consists of multiple services that work together:
| Service | Purpose | Dependencies |
|---|---|---|
| mb-rpcd | RPC daemon (core) | MariaDB, Redis |
| mb-filter | Email content filtering | mb-rpcd, Rspamd, ClamAV |
| mb-milter | Milter protocol interface | mb-rpcd |
| mb-eval | Email evaluation engine | mb-rpcd |
| mb-virtuoso | Mail virtualization | mb-rpcd |
| mb-scribe | Logging and analytics | mb-rpcd |
| mb-cron | Scheduled tasks | mb-rpcd |
| mb-guardian | Security monitoring | mb-rpcd |
All services managed by SystemD.
Service Status¶
Check All Services¶
Quick status check:
Example output:
Mailborder V6 System Status
============================
Core Services:
✓ mb-rpcd RUNNING (PID 1234, uptime 5d 12h)
✓ mb-filter RUNNING (PID 1235, uptime 5d 12h)
✓ mb-milter RUNNING (PID 1237, uptime 5d 12h)
✓ mb-eval RUNNING (PID 1238, uptime 5d 12h)
✓ mb-virtuoso RUNNING (PID 1239, uptime 5d 12h)
✓ mb-scribe RUNNING (PID 1240, uptime 5d 12h)
✓ mb-cron ENABLED (timer active)
✓ mb-guardian RUNNING (PID 1242, uptime 5d 12h)
Dependencies:
✓ MariaDB RUNNING (PID 987, uptime 10d 3h)
✓ Redis RUNNING (PID 988, uptime 10d 3h)
✓ Postfix RUNNING (PID 989, uptime 10d 3h)
✓ Rspamd RUNNING (PID 990, uptime 10d 3h)
✓ ClamAV RUNNING (PID 991, uptime 10d 3h)
✓ Nginx RUNNING (PID 992, uptime 10d 3h)
System Health: GOOD
CPU Usage: 15%
Memory Usage: 2.1 GB / 8.0 GB (26%)
Disk Usage: 45 GB / 100 GB (45%)
Individual Service Status¶
Using SystemD:
Example output:
● mb-rpcd.service - Mailborder RPC Daemon
Loaded: loaded (/etc/systemd/system/mb-rpcd.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2025-01-08 10:23:45 UTC; 5 days ago
Main PID: 1234 (mb-rpcd)
Tasks: 12 (limit: 4915)
Memory: 256.5M
CGroup: /system.slice/mb-rpcd.service
├─1234 /usr/libexec/mailborder/php_enc/mb-rpcd: main
├─1235 /usr/libexec/mailborder/php_enc/mb-rpcd: worker
├─1236 /usr/libexec/mailborder/php_enc/mb-rpcd: worker
└─1237 /usr/libexec/mailborder/php_enc/mb-rpcd: worker
Jan 13 14:23:45 mailborder systemd[1]: Started Mailborder RPC Daemon.
Compact status:
sudo systemctl is-active mb-rpcd # Returns: active or inactive
sudo systemctl is-enabled mb-rpcd # Returns: enabled or disabled
sudo systemctl is-failed mb-rpcd # Returns: failed or active
Starting Services¶
Start Individual Service¶
Start service:
Verify started:
Start All Mailborder Services¶
Start in correct order:
# Start core first
sudo systemctl start mb-rpcd
# Then start dependent services
sudo systemctl start mb-filter
sudo systemctl start mb-milter
sudo systemctl start mb-eval
sudo systemctl start mb-virtuoso
sudo systemctl start mb-scribe
sudo systemctl start mb-guardian
# Enable cron timer
sudo systemctl start mb-cron.timer
Or use helper script:
Start Dependencies¶
Start all required dependencies:
sudo systemctl start mariadb
sudo systemctl start redis-server
sudo systemctl start postfix
sudo systemctl start rspamd
sudo systemctl start clamav-daemon
sudo systemctl start nginx
sudo systemctl start php8.2-fpm
Stopping Services¶
Stop Individual Service¶
Stop service:
Verify stopped:
Stop All Mailborder Services¶
Stop all services:
# Stop dependent services first
sudo systemctl stop mb-filter
sudo systemctl stop mb-milter
sudo systemctl stop mb-eval
sudo systemctl stop mb-virtuoso
sudo systemctl stop mb-scribe
sudo systemctl stop mb-guardian
sudo systemctl stop mb-cron.timer
# Then stop core
sudo systemctl stop mb-rpcd
Or use helper:
Graceful vs Force Stop¶
Graceful stop (default):
Force stop:
Force stop signal:
Restarting Services¶
Restart Individual Service¶
Restart service:
This: 1. Stops the service 2. Waits for process to exit 3. Starts the service again
Quick restart check:
Restart All Services¶
Restart all Mailborder services:
Manual restart in order:
# Restart core first
sudo systemctl restart mb-rpcd
# Then restart dependent services
sudo systemctl restart mb-filter
sudo systemctl restart mb-milter
sudo systemctl restart mb-eval
sudo systemctl restart mb-virtuoso
sudo systemctl restart mb-scribe
sudo systemctl restart mb-guardian
Reload vs Restart¶
Reload (preferred - no downtime):
- Reloads configuration without stopping - No connection interruption - Faster than restartRestart (full stop/start):
- Stops and starts service - Brief downtime - Required for binary/library updatesWhen to reload: - Configuration file changes - Policy updates - Minor setting adjustments
When to restart: - Software updates - Library updates - Major configuration changes - Service malfunction
Enabling and Disabling Services¶
Enable Service (Auto-start on Boot)¶
Enable service:
Creates symlink:
Created symlink /etc/systemd/system/multi-user.target.wants/mb-rpcd.service
→ /etc/systemd/system/mb-rpcd.service.
Enable and start:
Disable Service¶
Disable service:
Disable and stop:
Check Enabled Status¶
Is service enabled?:
List all enabled Mailborder services:
Example output:
mb-cron.service enabled
mb-cron.timer enabled
mb-eval.service enabled
mb-filter.service enabled
mb-guardian.service enabled
mb-milter.service enabled
mb-rpcd.service enabled
mb-scribe.service enabled
mb-virtuoso.service enabled
Service Dependencies¶
Understanding Dependencies¶
View service dependencies:
Example output:
mb-filter.service
● ├─system.slice
● ├─mb-rpcd.service
● ├─rspamd.service
● ├─clamav-daemon.service
● └─sysinit.target
Reverse dependencies (what depends on this service):
Start Order¶
Correct startup order:
- Infrastructure:
- MariaDB
- Redis
- Nginx
-
PHP-FPM
-
Email Stack:
- Postfix
- Rspamd
-
ClamAV
-
Mailborder Core:
-
mb-rpcd (starts first, others depend on it)
-
Mailborder Services:
- mb-filter
- mb-milter
- mb-eval
- mb-virtuoso
- mb-scribe
- mb-guardian
- mb-cron
SystemD handles this automatically via unit file dependencies.
Service Logs¶
View Service Logs¶
Using journalctl (SystemD journal):
# All logs for service
sudo journalctl -u mb-rpcd
# Last 50 lines
sudo journalctl -u mb-rpcd -n 50
# Follow (real-time)
sudo journalctl -u mb-rpcd -f
# Since time
sudo journalctl -u mb-rpcd --since "1 hour ago"
sudo journalctl -u mb-rpcd --since "2025-01-13 14:00:00"
# Today only
sudo journalctl -u mb-rpcd --since today
# Between times
sudo journalctl -u mb-rpcd --since "2025-01-13 10:00:00" --until "2025-01-13 12:00:00"
Service-specific log files:
# Service logs in /var/log/mailborder/
sudo tail -f /var/log/mailborder/mb-rpcd.log
sudo tail -f /var/log/mailborder/mb-filter.log
sudo tail -f /var/log/mailborder/mb-milter.log
Log Filtering¶
Filter by priority:
# Errors only
sudo journalctl -u mb-filter -p err
# Warnings and above
sudo journalctl -u mb-filter -p warning
# Priority levels: emerg, alert, crit, err, warning, notice, info, debug
Search logs:
# Search for keyword
sudo journalctl -u mb-rpcd | grep ERROR
# Case-insensitive search
sudo journalctl -u mb-rpcd | grep -i error
Multiple services:
Service Performance¶
Resource Usage¶
CPU and memory per service:
Example output:
Using top:
Using ps:
Service Statistics¶
View service statistics:
Specific properties:
# Memory usage
sudo systemctl show mb-rpcd -p MemoryCurrent
# Active state
sudo systemctl show mb-rpcd -p ActiveState
# Uptime
sudo systemctl show mb-rpcd -p ActiveEnterTimestamp
Process Information¶
List processes:
# Main process
systemctl show mb-rpcd -p MainPID
# All processes
sudo systemctl status mb-rpcd | grep -A20 CGroup
Process tree:
Service Configuration¶
Unit File Location¶
Service files:
/etc/systemd/system/mb-rpcd.service
/etc/systemd/system/mb-filter.service
/etc/systemd/system/mb-milter.service
/etc/systemd/system/mb-eval.service
/etc/systemd/system/mb-virtuoso.service
/etc/systemd/system/mb-scribe.service
/etc/systemd/system/mb-cron.service
/etc/systemd/system/mb-cron.timer
/etc/systemd/system/mb-guardian.service
Edit Service Configuration¶
Edit service file:
Or directly:
After editing, reload SystemD:
Service Overrides¶
Create override (preferred):
Creates:
Example override:
Reload after changes:
Troubleshooting¶
Service Won't Start¶
Check status and errors:
Common issues:
-
Dependencies not running:
-
Port already in use:
-
Permission errors:
-
Configuration error:
Service Keeps Restarting¶
Check restart status:
View restart history:
Common causes: - Crashes on startup (check logs) - Database connection failures - Memory limit exceeded - Configuration errors
Disable auto-restart temporarily:
Add:
Then diagnose issue before re-enabling.
Service is Slow¶
Check resource usage:
Check logs for errors:
Adjust workers/threads:
Service Unresponsive¶
Check if process is running:
Check if accepting connections:
Send reload signal:
Force restart if needed:
Maintenance Tasks¶
Graceful Maintenance Window¶
Prepare for maintenance:
# 1. Stop accepting new email
sudo postfix stop
# 2. Wait for queue to clear
watch mailq
# 3. Stop Mailborder services
sudo mb-services stop
# 4. Perform maintenance
sudo apt upgrade
sudo mb-maintenance --all
# 5. Start services
sudo mb-services start
# 6. Resume mail
sudo postfix start
Service Updates¶
Update Mailborder:
# Stop services
sudo mb-services stop
# Update package
sudo apt update
sudo apt upgrade mailborder
# Reload SystemD (in case unit files changed)
sudo systemctl daemon-reload
# Start services
sudo mb-services start
# Verify
sudo mb-status
Clean Restart All¶
Complete clean restart:
# Stop all
sudo mb-services stop
sudo systemctl stop postfix rspamd clamav-daemon
# Clear temp files
sudo rm -rf /var/run/mailborder/*
sudo rm -rf /tmp/mbv6-*
# Restart dependencies
sudo systemctl restart mariadb
sudo systemctl restart redis-server
# Start mail stack
sudo systemctl start postfix
sudo systemctl start rspamd
sudo systemctl start clamav-daemon
# Start Mailborder
sudo mb-services start
# Verify
sudo mb-status
Best Practices¶
Service Management¶
- Always check dependencies first
- Ensure MariaDB and Redis are running
-
Check Postfix, Rspamd, ClamAV status
-
Use reload instead of restart when possible
- Faster
- No downtime
-
Preserves connections
-
Monitor logs during changes
-
Verify after changes
-
Document changes
- Keep notes of why services were restarted
- Track configuration changes
Automation¶
Create service check script:
#!/bin/bash
# /usr/local/bin/check-mailborder
SERVICES="mb-rpcd mb-filter mb-milter mb-eval mb-virtuoso mb-scribe mb-guardian"
for service in $SERVICES; do
if ! systemctl is-active --quiet $service; then
echo "Service $service is not running!"
# Send alert
mail -s "Mailborder Alert: $service down" admin@example.com <<< "Service $service is not running"
# Attempt restart
systemctl start $service
fi
done
Add to cron:
Add:
See Also¶
- Service Architecture - Service overview and architecture
- mb-rpcd - RPC daemon details
- mb-filter - Email filtering service
- Troubleshooting - Service troubleshooting