run(); (new Process(['systemctl', 'enable', 'supervisord']))->run(); } elseif (is_dir('/etc/supervisor/conf.d/')) { $extension = '.conf'; $directory = '/etc/supervisor/conf.d/'; } else { throw new \Exception('Supervisor config directory not found.'); } // Write the Supervisor config file file_put_contents($directory . 'laravel-queue' . $extension, $queue_worker); // Create log file and set proper permissions $logPath = '/var/www/queue-queue.log'; (new Process(['touch', $logPath]))->run(); (new Process(['chown', 'asterisk:asterisk', $logPath]))->run(); // Reload Supervisor configuration and restart the process (new Process(['supervisorctl', 'reread']))->run(); (new Process(['supervisorctl', 'update']))->run(); (new Process(['supervisorctl', 'restart', 'laravel-queue']))->run(); } public function down() { if (is_dir('/etc/supervisord.d/')) { $extension = '.ini'; $directory = '/etc/supervisord.d/'; } elseif (is_dir('/etc/supervisor/conf.d/')) { $extension = '.conf'; $directory = '/etc/supervisor/conf.d/'; } else { return; } // Remove Supervisor config and log file @unlink($directory . 'laravel-queue' . $extension); @unlink('/var/www/queue-queue.log'); // Reload Supervisor configuration and stop the process (new Process(['supervisorctl', 'reread']))->run(); (new Process(['supervisorctl', 'update']))->run(); (new Process(['supervisorctl', 'stop', 'laravel-queue']))->run(); } }