mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 04:01:24 +00:00
48 lines
1.2 KiB
PHP
48 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Models\Settings;
|
|
use Blacklight\Tmux;
|
|
use Illuminate\Console\Command;
|
|
use Symfony\Component\Process\Process;
|
|
|
|
class TmuxUIStop extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'tmux-ui:stop {type}';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'Stop the processing of tmux scripts.';
|
|
|
|
/**
|
|
* @throws \Exception
|
|
*/
|
|
public function handle()
|
|
{
|
|
if ($this->argument('type') !== null) {
|
|
(new Tmux())->stopIfRunning();
|
|
|
|
if ($this->argument('type') === 'true') {
|
|
$sessionName = Settings::settingValue('site.tmux.tmux_session');
|
|
$tmuxSession = new Process('tmux kill-session -t '.$sessionName);
|
|
$this->info('Killing active tmux session: '.$sessionName);
|
|
$tmuxSession->run();
|
|
if ($tmuxSession->isSuccessful()) {
|
|
$this->info('Tmux session killed successfully');
|
|
}
|
|
}
|
|
} else {
|
|
$this->error($this->description);
|
|
}
|
|
}
|
|
}
|