コード例 #1
0
ファイル: haproxy.php プロジェクト: BillTheBest/1.6.x
<?php

include_once dirname(__FILE__) . "/frame.class.inc";
include_once dirname(__FILE__) . "/class.unix.inc";
if (isset($_GET["status-instance"])) {
    status_instance();
    exit;
}
if (isset($_GET["statrt"])) {
    status_instance_stats();
    exit;
}
if (isset($_GET["start-instance"])) {
    start_instance();
    exit;
}
if (isset($_GET["stop-instance"])) {
    stop_instance();
    exit;
}
if (isset($_GET["restart-instance"])) {
    restart_instance();
    exit;
}
if (isset($_GET["restart-instance-silent"])) {
    restart_instance_silent();
    exit;
}
if (isset($_GET["build-instance"])) {
    build_instance();
    exit;
コード例 #2
0
function status_instance($ID)
{
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".{$ID}.pid";
    $pid = @file_get_contents($pidfile);
    $unix = new unix();
    if ($unix->process_exists($pid, basename(__FILE__))) {
        echo "Starting......: load-balancer engine Already executed PID {$pid}...\n";
        return;
    }
    @file_put_contents($pidfile, getmypid());
    $unix = new unix();
    $q = new mysql();
    $sql = "SELECT * FROM crossroads_main WHERE ID={$ID}";
    $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
    $xr = $unix->find_program("xr");
    if (!is_file($xr)) {
        return;
    }
    if (!isset($GLOBALS["XR_VERSION"])) {
        exec("{$xr} -V 2>&1", $results);
        while (list($index, $line) = each($results)) {
            if (preg_match("#XR version\\s+:.*?([0-9\\.]+)#", $line, $re)) {
                $GLOBALS["XR_VERSION"] = $re[1];
                break;
            }
        }
    }
    $pid = cross_pid($ID);
    $l[] = "[APP_CROSSROADS]";
    $l[] = "service_name=APP_CROSSROADS";
    $l[] = "master_version=" . $GLOBALS["XR_VERSION"];
    $l[] = "service_cmd=crossroads-src";
    $l[] = "service_disabled={$ligne["enabled"]}";
    $l[] = "pid_path={$pid_path}";
    $l[] = "pid={$pid}";
    $l[] = "watchdog_features=1";
    $l[] = "family=network";
    if ($ligne["enabled"] == 0) {
        return @implode("\n", $l);
    }
    if (!$GLOBALS["CLASS_UNIX"]->process_exists($pid)) {
        if ($GLOBALS["WATCHDOG"]) {
            crossroads_events("Instance was stopped from the watchdog -> start it", $ID, __FUNCTION__, __LINE__);
            start_instance($ID);
        }
        return @implode("\n", $l);
    }
    $l[] = $GLOBALS["CLASS_UNIX"]->GetMemoriesOf($pid);
    return @implode("\n", $l);
}