Repo for the search and displace ingest module that takes odf, docx and pdf and transforms it into .md to be used with search and displace operations
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

76 lines
2.1 KiB

<?php
namespace App\Console\Commands;
use Exception;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Storage;
class DeployWorker extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'queue:deploy-supervisor';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Adds the supervisorctl config file for laravel queues. Must be ran as root!';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$workerName = 'queue-worker-'.str_replace(' ', '-', strtolower(env('APP_NAME'))).'-'.str_replace(' ', '-', strtolower(env('APP_ENV')));
$workerFile = $workerName.'.conf';
try {
Storage::disk('supervisor')->put($workerFile, '[program:'.$workerName.']
process_name=%(program_name)s_%(process_num)02d');
Storage::disk('supervisor')->append($workerFile, 'command=php '.base_path().'/artisan queue:work');
Storage::disk('supervisor')->append($workerFile, 'autostart=true
autorestart=true
user=www-data
numprocs=1
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');
}
}