コード例 #1
0
ファイル: exec.memcached.php プロジェクト: brucewu16899/1.6.x
function PID_NUM()
{
    $filename = PID_PATH();
    $pid = trim(@file_get_contents($filename));
    $unix = new unix();
    if ($unix->process_exists($pid)) {
        return $pid;
    }
    return $unix->PIDOF($unix->find_program("memcached"));
}
コード例 #2
0
ファイル: exec.cntlm.php プロジェクト: brucewu16899/1.6.x
function PID_NUM()
{
    $filename = PID_PATH();
    $pid = trim(@file_get_contents($filename));
    $unix = new unix();
    if ($unix->process_exists($pid)) {
        return $pid;
    }
    $cntlm = $unix->find_program("cntlm");
    return $unix->PIDOF_PATTERN("{$cntlm}.*?cntlm\\.pid");
}
コード例 #3
0
ファイル: exec.stunnel.php プロジェクト: BillTheBest/1.6.x
function PID_NUM()
{
    $filename = PID_PATH();
    $pid = trim(@file_get_contents($filename));
    $unix = new unix();
    if ($unix->process_exists($pid)) {
        return $pid;
    }
    return $unix->PIDOF($unix->LOCATE_STUNNEL());
}
コード例 #4
0
function PID_NUM()
{
    $filename = PID_PATH();
    $pid = trim(@file_get_contents($filename));
    $unix = new unix();
    if ($unix->process_exists($pid)) {
        return $pid;
    }
    $lighttpd_bin = $unix->find_program("lighttpd");
    return $unix->PIDOF_PATTERN("{$lighttpd_bin} -f /etc/artica-postfix/squidguard-lighttpd.conf");
}
コード例 #5
0
ファイル: exec.postfix.php プロジェクト: BillTheBest/1.6.x
function stop($aspid = false)
{
    $unix = new unix();
    if (!$aspid) {
        $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
        $pid = $unix->get_pid_from_file($pidfile);
        if ($unix->process_exists($pid, basename(__FILE__))) {
            $time = $unix->PROCCESS_TIME_MIN($pid);
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: Postfix service Already Artica task running PID {$pid} since {$time}mn\n";
            }
            return;
        }
        @file_put_contents($pidfile, getmypid());
    }
    $pid = PID_NUM();
    if ($GLOBALS["OUTPUT"]) {
        echo "Stopping......: " . date("H:i:s") . " [INIT]: Postfix Pid file: " . PID_PATH() . "\n";
    }
    if (!$unix->process_exists($pid)) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Stopping......: " . date("H:i:s") . " [INIT]: Postfix service already stopped...\n";
        }
        return;
    }
    $postconf = $unix->find_program("postconf");
    $postfix = $unix->find_program("postfix");
    $pid = PID_NUM();
    $nohup = $unix->find_program("nohup");
    $php5 = $unix->LOCATE_PHP5_BIN();
    $kill = $unix->find_program("kill");
    if ($GLOBALS["OUTPUT"]) {
        echo "Stopping......: " . date("H:i:s") . " [INIT]: Postfix service Shutdown pid {$pid}...\n";
    }
    shell_exec("{$postfix} stop >/dev/null 2>&1");
    for ($i = 0; $i < 5; $i++) {
        $pid = PID_NUM();
        if (!$unix->process_exists($pid)) {
            break;
        }
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: Postfix service waiting pid:{$pid} {$i}/5...\n";
        }
        sleep(1);
    }
    $pid = PID_NUM();
    if (!$unix->process_exists($pid)) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Stopping......: " . date("H:i:s") . " [INIT]: Postfix service success...\n";
        }
        return;
    }
    if ($GLOBALS["OUTPUT"]) {
        echo "Stopping......: " . date("H:i:s") . " [INIT]: Postfix service shutdown - force - pid {$pid}...\n";
    }
    unix_system_kill_force($pid);
    for ($i = 0; $i < 5; $i++) {
        $pid = PID_NUM();
        if (!$unix->process_exists($pid)) {
            break;
        }
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: Postfix service waiting pid:{$pid} {$i}/5...\n";
        }
        sleep(1);
    }
    if (!$unix->process_exists($pid)) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Stopping......: " . date("H:i:s") . " [INIT]: Postfix service success...\n";
        }
        return;
    }
    if ($GLOBALS["OUTPUT"]) {
        echo "Stopping......: " . date("H:i:s") . " [INIT]: Postfix service failed...\n";
    }
}
コード例 #6
0
ファイル: exec.saslauthd.php プロジェクト: BillTheBest/1.6.x
function PID_NUM()
{
    $unix = new unix();
    $pid = $unix->get_pid_from_file(PID_PATH());
    if ($unix->process_exists($pid)) {
        return $pid;
    }
    $Masterbin = $unix->find_program("saslauthd");
    return $unix->PIDOF($Masterbin);
}