Example #1
0
function stopSyslog($saveOld = false)
{
    if ($saveOld) {
        // copy current memory log buffer to a temporary location
        exec("/sbin/logread > /tmp/messages.old", $discard, $result);
    }
    $result = stopProcess('syslogd', 'TERM');
    return $result;
}
 /**
  * Stops the development web server
  */
 function serverStop()
 {
     $pid = $this->getPID();
     if (!$pid) {
         $this->io->error("The server is already stopped");
     }
     stopProcess($pid);
     unlink($this->PID_FILE);
     $this->io->done("The web server is now <info>stopped</info>");
 }
Example #3
0
 * and selenium server. It writes a lock file to the cache file and as long as
 * the lock file exists the server runs. If we delete the file the server gets
 * shutdown. In this way we can spawn a process in the ant file and kill the
 * process when deleting the lock file.
 */
$service = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : null;
$action = isset($_SERVER['argv'][2]) ? $_SERVER['argv'][2] : null;
$iniFile = DIRECTORY_SEPARATOR === '\\' ? 'build-win.properties' : 'build-default.properties';
$config = parse_ini_file($iniFile);
// we are currently in the build dir we must change to the public dir to start
// a service
chdir(__DIR__ . '/../public');
$commands = ['webserver' => $config['php'] . ' -S 127.0.0.1:8008 server.php', 'webdriver' => $config['nodejs'] . ' fusio/node_modules/protractor/bin/webdriver-manager start'];
if (isset($commands[$service])) {
    if ($action == 'stop') {
        stopProcess($service);
    } else {
        startProcess($service, $commands[$service]);
    }
} else {
    echo 'Unknown service' . "\n";
    exit(1);
}
function startProcess($name, $cmd)
{
    echo 'Start ' . $name . ' (' . $cmd . ')' . "\n";
    $process = proc_open($cmd, array(), $pipes);
    $status = proc_get_status($process);
    $pid = $status['pid'];
    $file = __DIR__ . '/../cache/' . $name . '.lock';
    file_put_contents($file, $pid);
    stopProcess($press_server);
} else {
    while (true) {
        sleep(2);
        $curdir = "/home/work/renm/apache/apache2/htdocs/clientbest/tools/";
        $cmd = "sh " . $curdir . "is_press_running.sh " . $pid . " " . $press_server;
        $result = exec($cmd);
        //$fp = fopen("/home/work/renm/apache/apache2/htdocs/clientbest/web/tools/stop.log","a");
        //fwrite($fp,"$result\n");
        //fclose($fp);
        date_default_timezone_set('Asia/Chongqing');
        $date = date('Y-m-d H:i:s');
        echo $date . "   " . $result . "\n";
        if ($result < 1) {
            //has stop
            stopProcess($press_server, $data_id, $history_id);
            break;
        }
    }
}
function stopProcess($server, $data_id, $history_id)
{
    global $db;
    //get the current history_id and data_id
    //$sql = "select id,data_id from history_record order by id desc limit 1";
    //$result = mysql_query($sql,$db);
    //$row = mysql_fetch_array($result);
    //$id = $row["id"];
    //$data_id = $row["data_id"];
    //mysql_free_result($result);
    //update the data running