Beispiel #1
0
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"));
}
Beispiel #2
0
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");
}
Beispiel #3
0
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());
}
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");
}
Beispiel #5
0
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";
    }
}
Beispiel #6
0
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);
}