aboutcoders/supervisor-command-bundle
DEPRECATED. Symfony bundle adding console commands (abc:supervisor) to control Supervisor instances, built on YZSupervisorBundle. Install via Composer and register the bundle to manage Supervisor from app/console.
YZSupervisorBundle (its dependency) meets your needs directly. If not, consider alternatives like supervisor/supervisor or custom CLI scripts.composer require yzalis/supervisor-bundle sensio/framework-extra-bundle
config/bundles.php (Symfony 4+) or AppKernel.php (Symfony <4):
// config/bundles.php
return [
// ...
YZ\SupervisorBundle\YZSupervisorBundle::class => ['all' => true],
Abc\Bundle\SupervisorCommandBundle\AbcSupervisorCommandBundle::class => ['all' => true],
];
php bin/console list abc:supervisor
Expected output: Commands like abc:supervisor:start, abc:supervisor:stop, etc.Supervisor Process Management:
php bin/console abc:supervisor:start <process_name>
php bin/console abc:supervisor:restart-all
php bin/console abc:supervisor:tail <process_name>
php bin/console abc:supervisor:status
Integration with Symfony Workflows:
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\Routing\Annotation\Route;
/**
* @Route("/admin/supervisor/restart", name="supervisor_restart")
*/
public function restartAction() {
$this->get('command_handler')->execute('abc:supervisor:restart-all');
}
Event-Driven Triggers:
kernel.terminate) to auto-restart failed processes:
// src/EventListener/SupervisorListener.php
public function onTerminate(KernelEvents::TERMINATE, Event $event) {
$this->get('command_handler')->execute('abc:supervisor:status');
}
supervisord.conf is properly configured (e.g., supervisorctl rpcpipe path):
[rpcinterface:unix_http_server]
unix_http_server_file=/var/run/supervisor.sock
.env for dynamic paths:
SUPERVISOR_SOCKET=/var/run/supervisor.sock
Deprecation Warning:
YZSupervisorBundle or alternatives like:
spatie/laravel-supervisor (Laravel-specific).supervisorctl CLI calls via Symfony’s Process component.use Symfony\Component\Process\Process;
$process = new Process(['supervisorctl', 'restart', 'all']);
$process->run();
Permission Issues:
/var/run/supervisor.sock. Fix with:
sudo chown -R www-data:www-data /var/run/supervisor
supervisord to use a TCP socket (less secure but more flexible).Command Not Found:
abc:supervisor commands are missing, ensure:
config/bundles.php.YZSupervisorBundle is properly configured (check config.yml for yz_supervisor settings).Process Naming:
supervisorctl list
-v to commands for debugging:
php bin/console abc:supervisor:start my_process -v
/var/log/supervisor/supervisord.log for errors.Custom Commands:
MySupervisorCommand) and override logic:
namespace App\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class MySupervisorCommand extends Command {
protected function execute(InputInterface $input, OutputInterface $output) {
$supervisor = $this->getContainer()->get('yz_supervisor.supervisor');
$supervisor->restart('my_custom_process');
}
}
services.yaml:
commands:
app.my_supervisor: App\Command\MySupervisorCommand
Event Listeners:
yz_supervisor.process_state_change events to react to process failures:
// src/EventListener/ProcessListener.php
public function onProcessStateChange(ProcessStateChangeEvent $event) {
if ($event->getState() === ProcessStateChangeEvent::STATE_FAILED) {
$this->get('command_handler')->execute('abc:supervisor:restart', [$event->getProcessName()]);
}
}
Configuration Overrides:
yz_supervisor settings in config/packages/yz_supervisor.yaml:
yz_supervisor:
supervisor_socket: '%env(SUPERVISOR_SOCKET)%'
processes:
my_process:
command: 'php bin/console my:long-running-task'
autostart: true
restart-all instead of individual restarts to reduce overhead.
```markdown
## Alternatives Considered
| Feature | `aboutcoders/supervisor-command-bundle` | `YZSupervisorBundle` | `spatie/laravel-supervisor` | Custom `supervisorctl` |
|-----------------------|------------------------------------------|----------------------|-----------------------------|------------------------|
| **Process Control** | ✅ (Basic) | ✅ (Advanced) | ✅ (Laravel) | ✅ (Full) |
| **Symfony Integration** | ✅ (Commands) | ✅ (Services) | ✅ (Laravel) | ❌ (Manual) |
| **Event Hooks** | ❌ | ✅ | ❌ | ❌ |
| **Maintenance** | ❌ (Deprecated) | ✅ (Active) | ✅ (Active) | ✅ (Manual) |
| **Laravel Support** | ❌ | ❌ | ✅ | ❌ |
How can I help you explore Laravel packages today?