From aeb7012e6f149929c9891232becaf592cad544d2 Mon Sep 17 00:00:00 2001 From: Orzu Ionut Date: Mon, 10 Jan 2022 14:44:35 +0200 Subject: [PATCH] Update README for queue supervisor config --- README.md | 23 +++++++- app/Console/Commands/DeployWorker.php | 79 --------------------------- 2 files changed, 21 insertions(+), 81 deletions(-) delete mode 100644 app/Console/Commands/DeployWorker.php diff --git a/README.md b/README.md index a2faa8a..d549055 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,27 @@ cd DEWARP_INSTALLATION_DIRECTORY pip3 install -r requirements.txt ``` +### Queues Supervisor config +Add a new Supervisor config file in the "/etc/supervisor/conf.d" path like in the example below: + +Config file path: /etc/supervisor/conf.d/queue-worker-search-and-displace-ingest-production.conf + +```bash +[program:queue-worker-search-and-displace-ingest-production] +process_name=%(program_name)s_%(process_num)02d +command=php /var/www/html/searchanddisplace-ingest/artisan queue:listen --queue=sd_ingest,default --tries=2 --timeout=180 +autostart=true +autorestart=true +user=www-data +numprocs=3 +redirect_stderr=true +stdout_logfile=/var/log/queue/queue-worker-search-and-displace-ingest-production.log +``` + +The value for the 'command' key should reflect the app path (in the example above the app's path is "/var/www/html/searchanddisplace-ingest"). + +The 'stdout_logfile' value is the log file. All parent directories must already exist. + ### Install app ```bash # Generate environment file @@ -88,8 +109,6 @@ php artisan key:generate # Change the value for the QUEUE_CONNECTION to redis, if it is not set already # Deploy supervisor -php artisan queue:deploy-supervisor - supervisorctl start all ``` diff --git a/app/Console/Commands/DeployWorker.php b/app/Console/Commands/DeployWorker.php deleted file mode 100644 index 0bed20a..0000000 --- a/app/Console/Commands/DeployWorker.php +++ /dev/null @@ -1,79 +0,0 @@ -put($workerFile, '[program:'.$workerName.'] -process_name=%(program_name)s_%(process_num)02d'); - Storage::disk('supervisor')->append($workerFile, 'command=php '.base_path().'/artisan queue:listen --queue=sd_ingest,default --tries=2 --timeout=180'); - Storage::disk('supervisor')->append($workerFile, 'autostart=true -autorestart=true -user=www-data -numprocs=3 -redirect_stderr=true -stdout_logfile=/var/log/queue/'.$workerName.'.log'); - } catch (Exception $e) { - $this->info('supervisor script failed to install. Did you install supervisor and are you running this script as root?'); - - return; - } - - $this->info('supervisor script installed'); - - try { - exec('sudo supervisorctl reread'); - exec('sudo supervisorctl update'); - exec('sudo supervisorctl stop '.$workerName.':*');//in case it's already started - exec('sudo supervisorctl start '.$workerName.':*'); - } catch (Exception $e) { - $this->info('failed to start queue worker'); - - return; - } - - $this->info('queue worker started'); - } -}