diff --git a/app/Traits/Sofascore/GrappingTournaments.php b/app/Traits/Sofascore/GrappingTournaments.php index aec21e74..9942bf22 100644 --- a/app/Traits/Sofascore/GrappingTournaments.php +++ b/app/Traits/Sofascore/GrappingTournaments.php @@ -11,6 +11,8 @@ use App\Utilities\Notice; trait GrappingTournaments { + protected int $pid; + /** * Summary of grap_tournaments_for_day * @@ -24,17 +26,17 @@ trait GrappingTournaments Notice::note('⚽ tournaments for day '.$day); Notice::note('⚽ close all vpn'); } - exec('killall ssh'); + // exec('killall ssh'); if ($this->debug) { 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 */ if ($this->debug) { - Notice::note('get tournaments', 'g'); + Notice::note('get tournaments; pid: '.$this->pid, 'g'); } $this->day_tournaments = SofaScoreDayTournament::where('day', $day)->get(); @@ -47,7 +49,8 @@ trait GrappingTournaments if ($this->debug) { Notice::note('⚽ close all vpn'); } - exec('killall ssh'); + // exec('killall ssh'); + exec("kill $this->pid"); return; } else { @@ -188,7 +191,8 @@ trait GrappingTournaments Notice::note('⚽ close all vpn'); } - exec('killall ssh'); + // exec('killall ssh'); + exec("kill $this->pid"); } } }