2020-02-12 03:51:43 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
use Illuminate\Support\Facades\Artisan;
|
2020-03-11 01:38:11 +01:00
|
|
|
use Composer\Console\Application;
|
|
|
|
use Symfony\Component\Console\Input\ArrayInput;
|
2020-02-12 03:51:43 +01:00
|
|
|
|
|
|
|
class ArtisanUpgrade extends Command
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The name and signature of the console command.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $signature = 'ninja:post-update';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The console command description.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $description = 'Run basic upgrade commands';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new command instance.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the console command.
|
|
|
|
*
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function handle()
|
|
|
|
{
|
2020-03-11 01:38:11 +01:00
|
|
|
set_time_limit(0);
|
2020-02-12 03:51:43 +01:00
|
|
|
|
|
|
|
try {
|
|
|
|
Artisan::call('migrate');
|
2020-03-21 06:37:30 +01:00
|
|
|
} catch (Exception $e) {
|
2020-02-12 03:51:43 +01:00
|
|
|
\Log::error("I wasn't able to migrate the data.");
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
Artisan::call('optimize');
|
2020-03-21 06:37:30 +01:00
|
|
|
} catch (Exception $e) {
|
2020-02-12 03:51:43 +01:00
|
|
|
\Log::error("I wasn't able to optimize.");
|
|
|
|
}
|
|
|
|
|
2020-03-24 10:15:30 +01:00
|
|
|
// try {
|
|
|
|
// Artisan::call('queue:restart');
|
|
|
|
// } catch (Exception $e) {
|
|
|
|
// \Log::error("I wasn't able to restart the queue");
|
|
|
|
// }
|
|
|
|
|
2020-02-13 12:27:42 +01:00
|
|
|
try {
|
2020-03-24 10:15:30 +01:00
|
|
|
/* Restart Horizon */
|
2020-03-25 09:36:47 +01:00
|
|
|
//Artisan::call('horizon:terminate');
|
|
|
|
|
|
|
|
exec('cd '.base_path().' && /usr/bin/php artisan horizon:terminate');
|
|
|
|
exec('cd '.base_path().' && /usr/bin/php artisan horizon &');
|
|
|
|
|
|
|
|
//Artisan::call('horizon');
|
|
|
|
|
2020-03-21 06:37:30 +01:00
|
|
|
} catch (Exception $e) {
|
2020-03-24 10:15:30 +01:00
|
|
|
\Log::error("I wasn't able to start horizon");
|
2020-02-13 12:27:42 +01:00
|
|
|
}
|
2020-03-22 21:45:16 +01:00
|
|
|
|
|
|
|
putenv('COMPOSER_HOME=' . __DIR__ . '/vendor/bin/composer');
|
|
|
|
$input = new ArrayInput(array('command' => 'install'));
|
|
|
|
$application = new Application();
|
2020-03-25 09:36:47 +01:00
|
|
|
$application->setAutoExit(true); // prevent `$application->run` method from exitting the script
|
2020-03-22 21:45:16 +01:00
|
|
|
$application->run($input);
|
|
|
|
|
2020-02-12 03:51:43 +01:00
|
|
|
}
|
|
|
|
}
|