Laravel SSH - 关闭连接

时间:2016-02-16 15:21:09

标签: laravel

我有以下内容:

$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');

然而问题是我的$commands数组的最后一个命令运行游戏服务器,我相信应用程序正在等待命令完成运行,但它不会。

如何强制关闭会话以更新$server,然后重定向用户?

1 个答案:

答案 0 :(得分:2)

尝试在命令末尾添加&,这将运行非阻塞终端的命令,如下所示:

'./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.' &'