Ricky Barnett
Ricky Barnett

Reputation: 1170

Laravel SSH - close connection

I have the following:

$commands = [
            'cd steamcmd',
            'cd cs_go',
            './srcds_run -game csgo -console -usercon -ip '.$server->server_ip.' -maxplayers '.$server->slots.' +hostname '.$server->server_name.' +sv_setsteamaccount '.$server->server_token.' -port 27015 +game_type 0 +game_mode 1 +mapgroup mg_active +map de_dust2 -tickrate '.$server->tickrate.''
        ];
        \SSH::run($commands, function($line) {
            echo $line.PHP_EOL;
        });
        $server->status = 'Running';
        $server->save();
        return redirect('/control-panel/game-server');

However the issue is that the last command from my $commands array runs a game server and I believe the application is waiting for the command to finish running, but it wont.

How do I force close the session so that $server is updated then the user is redirected?

Upvotes: 1

Views: 289

Answers (1)

Fabio Antunes
Fabio Antunes

Reputation: 22862

Try putting a & at the end of your command, that will run the command non blocking your terminal, something like this:

'./srcds_run -game csgo -console -usercon -ip '.$server->server_ip.' -maxplayers '.$server->slots.' +hostname '.$server->server_name.' +sv_setsteamaccount '.$server->server_token.' -port 27015 +game_type 0 +game_mode 1 +mapgroup mg_active +map de_dust2 -tickrate '.$server->tickrate.' &'

Upvotes: 2

Related Questions