在symfony2中排队

时间:2014-12-05 08:34:56

标签: php symfony ssh queue

我有一个脚本,使用PHP中的SSH2命令连接到远程服务器。我想排队这个过程。

这是我想要排队的函数:

    if (!function_exists("ssh2_connect"))
    die("function ssh2_connect doesn't exist");

if (!($con = ssh2_connect("myipadresherenotshowingtoyouguys", 22))) {
    echo "fail: unable to establish connection\n";
} else {
    // try to authenticate with username root, password secretpassword
    if (!ssh2_auth_password($con, "blablabla", "blablabla!")) {
        echo "fail: unable to authenticate\n";
    } else {
        // allright, we're in!
        echo "okay: logged in...\n";

        // execute a command
        $command = 'ssid "Wentzo test2" hide-ssid';
        if (!($stream = ssh2_exec($con, $command))) {
            echo "fail: unable to execute command\n";
        } else {

            $stream2 = ssh2_exec($con, $command_save);
            // collect returning data from command
            stream_set_blocking($stream, true);
            $data = "";
            while ($buf = fread($stream, 4096)) {
                $data .= $buf;
            }

            fclose($stream);
        }
    }
}

有时我需要连接超过150台服务器,我认为排队这个过程是一个好习惯。

我的问题:我如何使用symfony2排队这个最好的方法?

也许是一些例子?!

由于

0 个答案:

没有答案