1 | <?php |
||
2 | |||
3 | namespace App\Console\Commands; |
||
4 | |||
5 | use App\Models\Settings; |
||
6 | use Blacklight\Tmux; |
||
7 | use Illuminate\Console\Command; |
||
8 | use Illuminate\Support\Facades\Process; |
||
9 | |||
10 | class TmuxUIStop extends Command |
||
11 | { |
||
12 | /** |
||
13 | * The name and signature of the console command. |
||
14 | * |
||
15 | * @var string |
||
16 | */ |
||
17 | protected $signature = 'tmux-ui:stop {--k|kill : kill the session}'; |
||
18 | |||
19 | /** |
||
20 | * The console command description. |
||
21 | * |
||
22 | * @var string |
||
23 | */ |
||
24 | protected $description = 'Stop the processing of tmux scripts.'; |
||
25 | |||
26 | /** |
||
27 | * @throws \Exception |
||
28 | */ |
||
29 | public function handle(): void |
||
30 | { |
||
31 | $tmux = new Tmux; |
||
32 | $tmux->stopIfRunning(); |
||
33 | if ($this->option('kill') === true) { |
||
0 ignored issues
–
show
introduced
by
![]() |
|||
34 | $sessionName = Settings::settingValue('tmux_session'); |
||
35 | $tmuxSession = Process::run('tmux kill-session -t '.$sessionName); |
||
36 | $this->info('Killing active tmux session: '.$sessionName); |
||
37 | if ($tmuxSession->successful()) { |
||
38 | $this->info('Tmux session killed successfully'); |
||
39 | } else { |
||
40 | $this->info('No valid tmux sessions found'); |
||
41 | } |
||
42 | } |
||
43 | } |
||
44 | } |
||
45 |