Overview
Thebench restart command restarts production services managed by Supervisor or systemd. This is used in production environments to apply changes after code updates, configuration changes, or to recover from errors.
Syntax
Options
Restart only the web workers (Gunicorn processes).
Restart Supervisor-managed processes. This is the default if no other options are specified.
Restart systemd units instead of Supervisor processes.
Usage Examples
Default Restart (Supervisor)
Restart all Supervisor-managed processes:Restart Web Workers Only
Restart only the Gunicorn web processes:- You’ve updated Python code
- You’ve changed configuration files
- Web workers are unresponsive
Restart systemd Services
For benches managed by systemd:Restart Web with systemd
Restart only web services under systemd:What Gets Restarted
Supervisor Mode (Default)
When using Supervisor, the following processes are restarted:- Web Workers: Gunicorn processes serving web requests
- Background Workers:
frappe-bench-workers:frappe-bench-frappe-default-worker-0frappe-bench-workers:frappe-bench-frappe-short-worker-0frappe-bench-workers:frappe-bench-frappe-long-worker-0
- Web Server: Node.js server
- SocketIO: Real-time communication server
- Scheduler: Background job scheduler
systemd Mode
When using systemd, these units are restarted:frappe-bench-web.service- Web serverfrappe-bench-workers.target- All worker servicesfrappe-bench-socketio.service- SocketIO serverfrappe-bench-redis-cache.service- Redis cache (if managed by systemd)frappe-bench-redis-queue.service- Redis queue (if managed by systemd)
Common Patterns
After Code Updates
Restart after pulling code changes:After Configuration Changes
Restart after modifying site config:Graceful Restart in Production
Minimize downtime with a rolling restart:Restart Individual Workers
For fine-grained control, use supervisorctl directly:When to Use
Restart Required
You must restart after:- Updating Python code in apps
- Modifying hooks.py
- Changing common_site_config.json
- Installing/updating Python packages
- Applying hotfixes
Restart NOT Required
You don’t need to restart after:- Changing JavaScript/CSS (just rebuild assets)
- Modifying DocType schemas (changes are immediate)
- Updating data in documents
- Changing site_config.json for most settings
Web-Only Restart Sufficient
Restart only web workers when:- You’ve only changed web-facing code
- Background workers are processing important jobs
- You want to minimize disruption
Supervisor vs systemd
Supervisor (Traditional)
Pros:- Simpler configuration
- Better log management
- Easier to debug
- More common in Frappe deployments
- Requires separate service
- Less integration with system
systemd (Modern)
Pros:- Native system integration
- Better resource management
- Automatic restart on failure
- Service dependencies
- More complex setup
- Logs via journalctl
- Less Frappe-specific tooling
Troubleshooting
Restart Command Hangs
If restart doesn’t complete:Workers Not Responding
Force restart with supervisorctl:Permission Denied
Restart commands may require sudo:Processes Not Starting
Check logs:Config Changes Not Applied
Force reload configuration:Zero-Downtime Restart
For mission-critical production:Monitoring Restarts
Check Process Status
View Logs During Restart
Verify Restart Success
Performance Impact
Restart Duration
Typical restart times:- Web workers: 5-10 seconds
- All processes: 15-30 seconds
- Large benches: 30-60 seconds
During Restart
- Active requests may fail
- Background jobs pause
- WebSocket connections drop
- Users may see connection errors
Minimize Impact
Automated Restart
Set up automatic restart on failure with Supervisor:Related Commands
bench start- Start development processesbench setup supervisor- Configure Supervisorbench setup systemd- Configure systemdbench reload- Reload configuration without restart