close only ssh session opened

This commit is contained in:
salam committed 2026-10-19 05:43:33 +02:00
1 parent fa89153a76
commit d05c24b96a
1 file changed
+9 -5
+9 -5
View File
@@ -11,6 +11,8 @@ use App\Utilities\Notice;
trait GrappingTournaments trait GrappingTournaments
{ {
protected int $pid;
/** /**
* Summary of grap_tournaments_for_day * Summary of grap_tournaments_for_day
* *
@@ -24,17 +26,17 @@ trait GrappingTournaments
Notice::note('⚽ tournaments for day '.$day); Notice::note('⚽ tournaments for day '.$day);
Notice::note('⚽ close all vpn'); Notice::note('⚽ close all vpn');
} }
exec('killall ssh'); // exec('killall ssh');
if ($this->debug) { if ($this->debug) {
Notice::note('⚽ open vpn'); Notice::note('⚽ open vpn');
} }
exec('ssh -f -N -L 13306:127.0.0.1:3306 -p 58371 root@162.55.242.190'); $this->pid = exec('ssh -f -N -L 13306:127.0.0.1:3306 -p 58371 root@162.55.242.190 > /dev/null 2>&1 & echo $!');
/** /**
* SofaScoreDayTournament * SofaScoreDayTournament
*/ */
if ($this->debug) { if ($this->debug) {
Notice::note('get tournaments', 'g'); Notice::note('get tournaments; pid: '.$this->pid, 'g');
} }
$this->day_tournaments = SofaScoreDayTournament::where('day', $day)->get(); $this->day_tournaments = SofaScoreDayTournament::where('day', $day)->get();
@@ -47,7 +49,8 @@ trait GrappingTournaments
if ($this->debug) { if ($this->debug) {
Notice::note('⚽ close all vpn'); Notice::note('⚽ close all vpn');
} }
exec('killall ssh'); // exec('killall ssh');
exec("kill $this->pid");
return; return;
} else { } else {
@@ -188,7 +191,8 @@ trait GrappingTournaments
Notice::note('⚽ close all vpn'); Notice::note('⚽ close all vpn');
} }
exec('killall ssh'); // exec('killall ssh');
exec("kill $this->pid");
} }
} }
} }