supervisorphp/supervisor
PHP client and wrapper for controlling Supervisor via its XML-RPC API. Manage processes, start/stop/restart programs, read status and logs, and integrate Supervisor control into Laravel or any PHP app with a simple, fluent interface.
supervisorphp/supervisor package enables programmatic interaction with Supervisor (a process control system) via XML-RPC, making it ideal for:
php artisan queue:work), scheduler, or event listeners. This package bridges the gap between Laravel’s task orchestration and Supervisor’s process control.curl/file_get_contents) are possible but less maintainable. This package abstracts complexity while retaining flexibility.ServiceProvider (e.g., SupervisorManager) to centralize process control logic.php artisan supervisor:restart queue-worker).job:failed → restart worker).[rpcinterface:unix:///tmp/supervisor.sock] in config).| Risk Area | Mitigation Strategy |
|---|---|
| Deprecated Package | Fork/maintain if critical; evaluate active alternatives (e.g., supervisor/supervisor Python SDK). |
| XML-RPC Vulnerabilities | Validate Supervisor’s XML-RPC security (authentication, input sanitization). |
| State Inconsistency | Implement idempotency (e.g., retry logic for transient failures). |
| Laravel Version Lock | Test against LTS Laravel versions (10.x, 11.x) to avoid breaking changes. |
queue-worker) to manage?Process wrapper (using Symfony’s Process component) suffice for simpler use cases?queue:work processes.database, redis, or beanstalkd queues.queue-worker.conf).php -r '$client = new \Supervisor\Client(); var_dump($client->getState());').SupervisorService class to test CRUD operations (e.g., restart a program).$supervisor = new \Supervisor\Client('unix:///tmp/supervisor.sock');
$supervisor->restart('queue-worker');
config/supervisor.php) for socket/timeout settings.$this->app->singleton(SupervisorClient::class, function () {
return new \Supervisor\Client(config('supervisor.socket'));
});
SupervisorCommand for CLI access:
php artisan supervisor:restart queue-worker
php artisan supervisor:status
composer install).STOPPED → auto-restart).composer.json to avoid breaking updates.config/supervisor/programs.php).'programs' => [
'queue-worker' => [
'command' => 'php artisan queue:work --sleep=3 --tries=3',
'numprocs' => 4,
],
],
try {
$supervisor->restart('worker');
} catch (\Supervisor\Exception\SupervisorException $e) {
Log::error('Supervisor restart failed', ['error' => $e->getMessage()]);
}
SUPERVISOR.md to the Laravel repo detailing:
numprocs can scale workers across Laravel instances (e.g., 4 workers per app server)..env to switch Supervisor sockets (e.g., SUPERVISOR_SOCKET=/var/run/supervisor.sock).| Failure Scenario | Mitigation |
|---|---|
| Supervisor Socket Unreachable | Fallback to CLI commands (system('supervisorctl restart queue-worker')). |
Worker Stuck in STOPPED |
Implement exponential backoff for restarts. |
| Supervisor Process Crash | Use Laravel’s Process component as a backup. |
| Permission Denied | Run Laravel app with same user as Supervisor (e.g., www-data). |
/etc/supervisor/supervisord.conf").How can I help you explore Laravel packages today?