Proc_Open in PHP and Pipes

时间:2011-05-30 21:19:36

标签: java php daemon proc-open

这是一个通过mysql服务器在web界面上控制minecraftserver的源代码。 一切都很好,除了第29行,似乎没有被执行。在服务器cin中根本没有出现任何东西。也没有发生任何事情......有没有人有想法,为什么会这样?

<?php
    echo("Successfully Loaded.\n");
    include("../src/func.php");
    $descriptorspec = array(
    0 => array("pipe", "r"),
    1 => array("pipe", "w"),
    2 => array("file", "../log/server.log", "a"));
    $cwd = '';
    $outpt = "../log/server.log";
    $ru_file = "runlevel.state";
    echo("Starting Server...\n");
    $process = proc_open('java -Xincgc -Xmx640M -jar craftbukkit.jar', $descriptorspec, $pipes, $cwd, $_ENV);
    $log_handle = fopen($outpt,"w");
    echo("Starting Daemon...\n");
    $run = 1;
    while($run == 1)
    {
        $handle = fopen($ru_file,"r");
        $run = (int)fread($handle, filesize($ru_file));
        fclose($handle);
        $mysqli = mopen();
        $query = $mysqli -> prepare("SELECT ID, Command, Urheber FROM tbl_cmds WHERE passed = '0'");
        echo($mysqli->error);
        $query -> execute();
        $query -> store_result();
        $query -> bind_result($id, $command, $who);
        while($query -> fetch())
        {
            fwrite($pipes[0], $command);
            $datum = date("d.m.Y H:i:s",time());
            echo("[$datum] Executed command '$command' by User with ID ($who)\n");
            $mysqli2 = mopen();
            $query2 = $mysqli2 -> prepare("UPDATE tbl_cmds SET passed = 1 WHERE ID = ?");
            echo($mysqli2->error);
            $query2 -> bind_param("i", $id);
            $query2 -> execute();
        }
    }
    echo("Daemon Stopped...\n");
    fclose($pipes[0]);
    fclose($log_handle);
    proc_close($process);
    echo("Server Stopped...\n");
    echo("Exiting with code 0x0...\n");
?>

0 个答案:

没有答案