mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 01:08:56 +00:00
Update tmux starting and stopping commands with option to kill tmux session (in stop command)
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Tmux;
|
||||
use Illuminate\Console\Command;
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
@@ -12,14 +13,15 @@ class TmuxUIStop extends Command
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'tmux-ui:stop';
|
||||
protected $signature = 'tmux-ui:stop {type}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Stop tmux processing';
|
||||
protected $description = 'Stop the processing of tmux scripts. This is functionally equivalent to unsetting the
|
||||
\'tmux running\' setting in admin. Usage: tmux-ui:stop false (does not kill tmux session), while using true will kill current tmux session';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
@@ -37,16 +39,37 @@ class TmuxUIStop extends Command
|
||||
* @return mixed
|
||||
* @throws \Symfony\Component\Process\Exception\LogicException
|
||||
* @throws \Symfony\Component\Process\Exception\RuntimeException
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$process = new Process('php misc/update/nix/tmux/stop.php');
|
||||
$process->run(function ($type, $buffer) {
|
||||
if (Process::ERR === $type) {
|
||||
echo 'ERR > '.$buffer;
|
||||
} else {
|
||||
echo $buffer;
|
||||
if ($this->argument('type') === 'false' || $this->argument('type') === 'true') {
|
||||
$process = new Process('php misc/update/nix/tmux/stop.php');
|
||||
$process->run(function ($type, $buffer) {
|
||||
if (Process::ERR === $type) {
|
||||
echo 'ERR > ' . $buffer;
|
||||
} else {
|
||||
echo $buffer;
|
||||
}
|
||||
}
|
||||
});
|
||||
);
|
||||
|
||||
if ($this->argument('type') === 'true') {
|
||||
|
||||
$sessionName = Tmux::value('tmux_session');
|
||||
$tmuxSession = new Process('tmux kill-session -t ' . $sessionName);
|
||||
$this->info('Killing active tmux session: ' . $sessionName);
|
||||
$tmuxSession->run(function ($type, $buffer) {
|
||||
if (Process::ERR === $type) {
|
||||
echo 'ERR > ' . $buffer;
|
||||
} else {
|
||||
echo $buffer;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}else {
|
||||
$this->error($this->description);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user