Files
newznab-tmux/app/Console/Commands/TmuxUIStart.php
T
DariusIII bc123e6e01 Apply fixes from StyleCI
[ci skip] [skip ci]
2018-09-05 10:28:46 +00:00

50 lines
1.3 KiB
PHP

<?php
namespace App\Console\Commands;
use Blacklight\Tmux;
use App\Models\Settings;
use Blacklight\ColorCLI;
use Illuminate\Console\Command;
class TmuxUIStart extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'tmux-ui:start';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Start the processing of tmux scripts.';
/**
* Execute the console command.
*/
public function handle()
{
$tmux = new Tmux();
$tmux_session = Settings::settingValue('site.tmux.tmux_session') ?? 0;
// Set running value to on.
$tmux->startRunning();
// Create a placeholder session so tmux commands do not throw server not found errors.
exec('tmux new-session -ds placeholder 2>/dev/null');
//check if session exists
$session = shell_exec("tmux list-session | grep $tmux_session");
// Kill the placeholder
exec('tmux kill-session -t placeholder');
if ($session === null) {
ColorCLI::doEcho(ColorCLI::info('Starting the tmux server and monitor script.'), true);
passthru('php '.app()->/* @scrutinizer ignore-call */ path().'/../misc/update/tmux/run.php');
}
}
}