远程重启Supervisor求助:ServerA、ServerB的Supervisor远程重启失败
Hey there! Let's work through this remote Supervisor restart issue together. Since your SSH keys are already configured properly, we can cross authentication problems off the list—nice work getting that sorted!
1. Verify Supervisorctl Path & Execution Permissions
Most of the time, the issue boils down to either the supervisorctl binary not being in your remote user's default PATH, or the user lacking permission to manage Supervisor processes.
- First, log into one of your target servers (e.g., ServerA) and run
which supervisorctlto get the full path, like/usr/bin/supervisorctlor/usr/local/bin/supervisorctl. - Then, use that full path in your remote command from ServerRemote:
ssh your-user@ServerA "/usr/bin/supervisorctl restart all" - If Supervisor requires sudo access (which it usually does, since it manages system processes), you'll need to set up passwordless sudo for the
supervisorctlcommand on the target servers. Edit/etc/sudoers(usevisudoto avoid syntax errors) and add a line like:
Then update your remote command to include sudo:your-user ALL=(ALL) NOPASSWD: /usr/bin/supervisorctlssh your-user@ServerA "sudo /usr/bin/supervisorctl restart all"
2. Check if Supervisor Service is Running
Sometimes supervisorctl fails because the underlying Supervisor service isn't active. You can check this remotely:
ssh your-user@ServerA "/usr/bin/supervisorctl status"
If you get an error like unix:///var/run/supervisor.sock no such file, start the Supervisor service first:
# For systemd-based systems (Ubuntu 16.04+, CentOS 7+) ssh your-user@ServerA "sudo systemctl start supervisor" # For older systems using init.d ssh your-user@ServerA "sudo service supervisor start"
3. Batch Manage Multiple Servers Easily
Since you have two servers to manage, a simple script can save you from repeating commands. Create a script named restart_supervisor.sh:
#!/bin/bash # List your servers in the format "user@server-address" SERVERS=("your-user@ServerA" "your-user@ServerB") # Use the full supervisorctl path you found earlier SUPERVISORCTL="/usr/bin/supervisorctl" for server in "${SERVERS[@]}" do echo "=== Restarting Supervisor on $server ===" ssh $server "sudo $SUPERVISORCTL restart all" done
Make it executable and run it:
chmod +x restart_supervisor.sh ./restart_supervisor.sh
4. Capture Full Error Details
If you're still hitting errors, capture the full error output to diagnose exactly what's wrong:
ssh your-user@ServerA "sudo /usr/bin/supervisorctl restart all" 2>&1
This will show you specific issues like permission denied, invalid configuration files, or socket connection failures—then you can address the root cause directly.
内容的提问来源于stack exchange,提问作者SanS




