当前位置: 首页>>代码示例>>PHP>>正文


PHP unix_system_kill_force函数代码示例

本文整理汇总了PHP中unix_system_kill_force函数的典型用法代码示例。如果您正苦于以下问题:PHP unix_system_kill_force函数的具体用法?PHP unix_system_kill_force怎么用?PHP unix_system_kill_force使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了unix_system_kill_force函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: parse

function parse()
{
    $TimeFile = "/etc/artica-postfix/pids/exec.squid.stats.mime.proto.php.time";
    $pidfile = "/etc/artica-postfix/pids/exec.squid.stats.mime.proto.php.pid";
    $GLOBALS["LogFileDeamonLogDir"] = @file_get_contents("/etc/artica-postfix/settings/Daemons/LogFileDeamonLogDir");
    if ($GLOBALS["LogFileDeamonLogDir"] == null) {
        $GLOBALS["LogFileDeamonLogDir"] = "/home/artica/squid/realtime-events";
    }
    $unix = new unix();
    $pid = $unix->get_pid_from_file($pidfile);
    if ($unix->process_exists($pid, basename(__FILE__))) {
        $timepid = $unix->PROCCESS_TIME_MIN($pid);
        if ($GLOBALS["VERBOSE"]) {
            echo "{$pid} already executed since {$timepid}Mn\n";
        }
        if ($timepid < 14) {
            return;
        }
        $kill = $unix->find_program("kill");
        unix_system_kill_force($pid);
    }
    @file_put_contents($pidfile, getmypid());
    $TimeExec = $unix->file_time_min($TimeFile);
    if (!$GLOBALS["FORCE"]) {
        if ($TimeExec < 20) {
            return;
        }
    }
    @unlink($TimeFile);
    @file_put_contents($TimeFile, time());
    parsedb("/var/log/squid");
    parsedb($GLOBALS["LogFileDeamonLogDir"]);
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:33,代码来源:exec.squid.stats.proto.parser.php

示例2: start_hour

function start_hour()
{
    $TimeFile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".time";
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".pid";
    $unix = new unix();
    $sock = new sockets();
    if (system_is_overloaded(basename(__FILE__))) {
        return;
    }
    $pid = @file_get_contents($pidfile);
    if ($pid < 100) {
        $pid = null;
    }
    if ($unix->process_exists($pid, basename(__FILE__))) {
        $timepid = $unix->PROCCESS_TIME_MIN($pid);
        if ($GLOBALS["VERBOSE"]) {
            echo "{$pid} already executed since {$timepid}Mn\n";
        }
        if (!$GLOBALS["FORCE"]) {
            if ($timepid < 14) {
                return;
            }
            $kill = $unix->find_program("kill");
            unix_system_kill_force($pid);
        }
    }
    @unlink($TimeFile);
    @file_put_contents($TimeFile, time());
    $hostname = $unix->hostname_g();
    $today = date("Y-m-d") . " 00:00:00";
    $postgres = new postgres_sql();
    $results = $postgres->QUERY_SQL("select date_trunc('H',zdate) + (round(extract('minute' from zdate)/15)*15) * '1 minute'::interval as time, sum(rx) as rx, sum(tx) as tx,eth from access_log WHERE proxyname='{$hostname}' AND zdate >'{$today}' group by time,eth");
    $c = 0;
    $f = array();
    while ($ligne = @pg_fetch_assoc($results)) {
        $time = $ligne["time"];
        $ETH = $ligne["eth"];
        if ($ETH == "lo") {
            continue;
        }
        $RX = $ligne["rx"];
        $TX = $ligne["tx"];
        $f[] = "('{$time}','{$ETH}','{$RX}','{$TX}')";
    }
    if (count($f) == 0) {
        return;
    }
    $q = new mysql();
    if ($q->TABLE_EXISTS("RXTX_HOUR", "artica_events")) {
        $q->QUERY_SQL("TRUNCATE TABLE `RXTX_HOUR`", "artica_events");
    }
    $sql = "CREATE TABLE IF NOT EXISTS `RXTX_HOUR`\n\t(`ZDATE` DATETIME,\n\t`RX` INT UNSIGNED NOT NULL DEFAULT 1,\n\t`TX` INT UNSIGNED NOT NULL DEFAULT 1,\n\t`ETH` VARCHAR(60),\n\tKEY `ZDATE`(`ZDATE`),\n\tKEY `RX`(`RX`),\n\tKEY `TX`(`TX`),\n\tKEY `ETH`(`ETH`) )  ENGINE = MYISAM;";
    $q->QUERY_SQL($sql, "artica_events");
    if (!$q->ok) {
        return;
    }
    $q->QUERY_SQL("INSERT IGNORE INTO RXTX_HOUR (ZDATE,ETH,RX,TX) VALUES " . @implode(",", $f), "artica_events");
    start_week();
}
开发者ID:articatech,项目名称:artica,代码行数:59,代码来源:exec.rxtx.hourly.php

示例3: ScanFoldders

function ScanFoldders()
{
    $sock = new sockets();
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $timefile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    $pid = file_get_contents("{$pidfile}");
    if ($GLOBALS["VERBOSE"]) {
        echo "{$timefile}\n";
    }
    if (system_is_overloaded(basename(__FILE__))) {
        die;
    }
    if ($unix->process_exists($pid, basename(__FILE__))) {
        $timeMin = $unix->PROCCESS_TIME_MIN($pid);
        if ($timeMin > 240) {
            system_admin_events("Too many TTL, {$pid} will be killed", __FUNCTION__, __FILE__, __LINE__, "logrotate");
            $kill = $unix->find_program("kill");
            unix_system_kill_force($pid);
        } else {
            die;
        }
    }
    if (!$GLOBALS["FORCE"]) {
        $TimeExec = $unix->file_time_min($timefile);
        if ($TimeExec < 240) {
            return;
        }
    }
    @unlink($timefile);
    @file_put_contents($timefile, time());
    $LogRotatePath = $sock->GET_INFO("LogRotatePath");
    $SystemLogsPath = $sock->GET_INFO("SystemLogsPath");
    $BackupMaxDaysDir = $sock->GET_INFO("BackupMaxDaysDir");
    $maillogStoragePath = trim(@file_get_contents("/etc/artica-postfix/settings/Daemons/maillogStoragePath"));
    if ($GLOBALS["VERBOSE"]) {
        echo "Starting Main\n";
    }
    $q = new mysql();
    $q->QUERY_SQL("DROP TABLE `sysstorestatus`", "artica_events");
    $sql = "CREATE TABLE IF NOT EXISTS `sysstorestatus` (\n\t\t\t  `filepath` VARCHAR(255) NOT NULL,\n\t\t\t  `filesize`  BIGINT UNSIGNED NOT NULL,\n\t\t\t  `zDate` DATETIME,\n\t\t\t  PRIMARY KEY (`filepath`),\n\t\t\t  KEY `zDate` (`zDate`),\n\t\t\t  KEY `filesize` (`filesize`)\n\t\t\n\t\t\t)";
    $q->QUERY_SQL($sql, "artica_events");
    if (!$q->ok) {
        echo $q->mysql_error;
        return;
    }
    ScanThis("/home/postfix/maillog");
    ScanThis("/home/logrotate");
    ScanThis("/home/logrotate_backup");
    ScanThis("/home/logs-backup");
    ScanThis("/home/backup/postfix");
    ScanThis($LogRotatePath);
    ScanThis($SystemLogsPath);
    ScanThis($maillogStoragePath);
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:55,代码来源:exec.scan.storage-logs.php

示例4: ParseMainDir

function ParseMainDir()
{
    $unix = new unix();
    $mypid = getmypid();
    $kill = $unix->find_program("kill");
    $nohup = $unix->find_program("nohup");
    $php5 = $unix->LOCATE_PHP5_BIN();
    @mkdir("/etc/artica-postfix/pids", 0755, true);
    $pidtime = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".time";
    $pidtime_hour = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".hours.time";
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".pid";
    $pid = @file_get_contents($pidfile);
    if ($pid < 100) {
        $pid = null;
    }
    if ($unix->process_exists($pid, basename(__FILE__))) {
        $time = $unix->PROCCESS_TIME_MIN($pid);
        if ($time > 60) {
            unix_system_kill_force($pid);
        } else {
            events("Already executed pid {$pid} since {$time}mn-> DIE");
            if ($GLOBALS["VERBOSE"]) {
                echo "Already executed pid {$pid} since {$time}mn\n";
            }
            die;
        }
    }
    $timeP = $unix->file_time_min($pidtime);
    if ($timeP < 3) {
        events("Main::Line: " . __LINE__ . " 3Mn minimal current: {$timeP}mn-> DIE");
        die;
    }
    @unlink($pidtime);
    @file_put_contents($pidtime, time());
    @file_put_contents($pidfile, $mypid);
    $dirs = $unix->dirdir("/var/log/artica-postfix/squid/queues");
    while (list($directory, $array) = each($dirs)) {
        $dirs2 = $unix->dirdir($directory);
        if (count($dirs2) == 0) {
            events("{$dirs2} 0 elements, remove...", __LINE__);
            @rmdir($directory);
            continue;
        }
        if (is_dir("{$directory}/SearchWords")) {
            events("Scanning {$directory}/SearchWords", __LINE__);
            ParseSubDir("{$directory}/SearchWords");
        }
    }
    $timeP = $unix->file_time_min($pidtime_hour);
    if ($timeP > 30) {
        @unlink($pidtime_hour);
        @file_put_contents($pidtime_hour, time());
        shell_exec("{$nohup} {$php5} /usr/share/artica-postfix/exec.squid-searchwords.php --hour >/dev/null 2>&1");
    }
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:55,代码来源:exec.squid.words.parsers.php

示例5: parse

function parse()
{
    $TimeFile = "/etc/artica-postfix/pids/exec.squid.stats.quota-week.parser.php.time";
    $pidfile = "/etc/artica-postfix/pids/exec.squid.stats.quota-week.parser.php.pid";
    $unix = new unix();
    $pid = $unix->get_pid_from_file($pidfile);
    if ($unix->process_exists($pid, basename(__FILE__))) {
        $timepid = $unix->PROCCESS_TIME_MIN($pid);
        if ($GLOBALS["VERBOSE"]) {
            echo "{$pid} already executed since {$timepid}Mn\n";
        }
        if ($timepid < 14) {
            return;
        }
        $kill = $unix->find_program("kill");
        unix_system_kill_force($pid);
    }
    @file_put_contents($pidfile, getmypid());
    $sock = new sockets();
    $SquidPerformance = intval($sock->GET_INFO("SquidPerformance"));
    $time = $unix->file_time_min($TimeFile);
    if (!$GLOBALS["FORCE"]) {
        if ($time < 1440) {
            return;
        }
    }
    @unlink($TimeFile);
    @file_put_contents($TimeFile, time());
    $f = $unix->DirFiles("/var/log/squid", "[0-9]+_QUOTASIZE\\.db");
    $export_path = "/home/artica/squid/dbExport";
    @mkdir($export_path, 0755, true);
    while (list($filename, $none) = each($f)) {
        preg_match("#([0-9]+)_#", $filename, $re);
        $xdate = $re[1];
        echo "{$filename} ( {$xdate} )\n";
        if ($SquidPerformance > 1) {
            if (!@copy("/var/log/squid/{$filename}", "{$export_path}/{$filename}")) {
                continue;
            }
            @unlink("/var/log/squid/{$filename}");
            continue;
        }
        if (!parse_file("/var/log/squid/{$filename}", $xdate)) {
            continue;
        }
        if (!@copy("/var/log/squid/{$filename}", "{$export_path}/{$filename}")) {
            continue;
        }
        @unlink("/var/log/squid/{$filename}");
    }
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:51,代码来源:exec.squid.stats.quota-week.parser.php

示例6: watchdog

function watchdog($maxProcesses = 50)
{
    $unix = new unix();
    $pdns_server = $unix->find_program("pdns_server");
    $pdns_recursor = $unix->find_program("pdns_recursor");
    $pidof = $unix->find_program("pidof");
    $kill = $unix->find_program("kill");
    echo "pdns_server = {$pdns_server}\n";
    echo "pdns_recursor = {$pdns_recursor}\n";
    exec("{$pidof} {$pdns_server} 2>&1", $results);
    $string = @implode("", $results);
    $exploded = @explode(" ", $string);
    while (list($num, $val) = each($exploded)) {
        if (!is_numeric($val)) {
            echo "skip {$val}\n";
            continue;
        }
        $PIDS[$val] = $val;
    }
    echo count($PIDS) . " processes <> {$maxProcesses} for {$pdns_server}\n";
    if (count($PIDS) > $maxProcesses) {
        echo "Watchdog GO -> kill {$pdns_server} !\n";
        while (list($num, $int) = each($PIDS)) {
            echo "Killing {$pdns_server} pid {$num}\n";
            unix_system_kill_force($num);
        }
        $PIDS = array();
        exec("{$pidof} {$pdns_recursor} 2>&1", $results);
        $string = @implode("", $results);
        $exploded = @explode(" ", $string);
        while (list($num, $val) = each($exploded)) {
            if (!is_numeric($val)) {
                continue;
            }
            $PIDS[$val] = $val;
        }
        echo count($PIDS) . " processes <> {$maxProcesses} for {$pdns_recursor}\n";
        while (list($num, $int) = each($PIDS)) {
            echo "Killing {$pdns_recursor} pid {$num} \n";
            unix_system_kill_force($num);
        }
    }
    echo "Finish\n";
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:44,代码来源:exec.powerdns.watchdog.php

示例7: start

function start()
{
    // /etc/artica-postfix/pids/exec.loadavg.php.start.time
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $pidfileTime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    if ($GLOBALS["VERBOSE"]) {
        echo "{$pidfileTime}\n";
    }
    if (!$GLOBALS["VERBOSE"]) {
        if ($unix->file_time_min($pidfileTime) < 59) {
            return;
        }
    }
    $pid = @file_get_contents($pidfile);
    if ($pid < 100) {
        $pid = null;
    }
    if ($unix->process_exists($pid, basename(__FILE__))) {
        $timepid = $unix->PROCCESS_TIME_MIN($pid);
        if ($GLOBALS["VERBOSE"]) {
            echo "{$pid} already executed since {$timepid}Mn\n";
        }
        if ($timepid < 15) {
            return;
        }
        $kill = $unix->find_program("kill");
        unix_system_kill_force($pid);
    }
    @file_put_contents($pidfile, getmypid());
    if (system_is_overloaded()) {
        if ($GLOBALS["VERBOSE"]) {
            echo "Overloaded\n";
        }
        die;
    }
    @unlink($pidfileTime);
    @file_put_contents($pidfileTime, time());
    if ($GLOBALS["VERBOSE"]) {
        echo "cpustats\n";
    }
    cpustats();
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:43,代码来源:exec.loadavg.php

示例8: stop

function stop($id)
{
    $unix = new unix();
    $sql = "SELECT * FROM imapsync WHERE ID='{$id}'";
    $q = new mysql();
    $ligne = @mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
    if (!$q->ok) {
        write_syslog("Mysql error {$q->mysql_error}", __FILE__);
        die;
    }
    $pid_org = $ligne["pid"];
    $ligne["imap_server"] = str_replace(".", "\\.", $ligne["imap_server"]);
    $ligne["username"] = str_replace(".", "\\.", $ligne["username"]);
    exec($unix->find_program("pgrep") . " -f \"imapsync.+?--host1 {$ligne["imap_server"]}.+?--user1 {$ligne["username"]}\"", $pids);
    while (list($index, $pid) = each($pids)) {
        if ($pid > 5) {
            unix_system_kill_force($pid);
        }
    }
    unix_system_kill_force($pid_org);
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:21,代码来源:exec.mailsync.php

示例9: run

function run()
{
    $TimeFile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".time";
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".pid";
    $unix = new unix();
    $tmpfile = $unix->FILE_TEMP();
    $pid = $unix->get_pid_from_file($pidfile);
    if ($unix->process_exists($pid, basename(__FILE__))) {
        $timepid = $unix->PROCCESS_TIME_MIN($pid);
        if ($GLOBALS["VERBOSE"]) {
            echo "{$pid} already executed since {$timepid}Mn\n";
        }
        if (!$GLOBALS["FORCE"]) {
            if ($timepid < 14) {
                return;
            }
            $kill = $unix->find_program("kill");
            unix_system_kill_force($pid);
        }
    }
    @file_put_contents($pidfile, getmypid());
    if (!$GLOBALS["FORCE"]) {
        if (!$GLOBALS["VERBOSE"]) {
            $time = $unix->file_time_min($TimeFile);
            if ($time < 14) {
                echo "Current {$time}Mn, require at least 14mn\n";
                return;
            }
        }
    }
    $binary = "/usr/share/artica-postfix/bin/pflogsumm.pl";
    @chmod("{$binary}", 0755);
    system("{$binary} -d today /var/log/mail.log >{$tmpfile}");
    ParseReport($tmpfile);
    @unlink($tmpfile);
    stats_total();
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:37,代码来源:exec.pflogsumm.php

示例10: stop

function stop($aspid = false)
{
    $unix = new unix();
    $kill = $unix->find_program("kill");
    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 "Stopping......: " . date("H:i:s") . " [INIT]: nginx-tail, Already task running PID {$pid} since {$time}mn\n";
            }
            return;
        }
        @file_put_contents($pidfile, getmypid());
    }
    $pid = GETPID();
    if (!$unix->process_exists($pid)) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Stopping......: " . date("H:i:s") . " [INIT]: nginx-tail, already stopped\n";
        }
        return;
    }
    if ($GLOBALS["OUTPUT"]) {
        echo "Stopping......: " . date("H:i:s") . " [INIT]: nginx-tail, stopping pid: {$pid}\n";
    }
    unix_system_kill_force($pid);
    for ($i = 0; $i < 6; $i++) {
        $pid = GETPID();
        if (!$unix->process_exists($pid)) {
            break;
        }
        if ($GLOBALS["OUTPUT"]) {
            echo "Stopping......: " . date("H:i:s") . " [INIT]: nginx-tail, waiting pid: {$pid} {$i}/5\n";
        }
        unix_system_kill_force($pid);
        sleep(1);
    }
    $tail = $unix->find_program("tail");
    $pid = $unix->PIDOF("/bin/nginx-tail");
    if ($unix->process_exists($pid)) {
        for ($i = 0; $i < 20; $i++) {
            if ($GLOBALS["OUTPUT"]) {
                echo "Stopping......: " . date("H:i:s") . " [INIT]: killing old process pid {$pid}\n";
            }
            unix_system_kill_force($pid);
            usleep(800);
            $pid = $unix->PIDOF("/bin/access-tail");
            if (!$unix->process_exists($pid)) {
                break;
            }
            unix_system_kill_force($pid);
        }
    }
    $pid = GETPID();
    if (!$unix->process_exists($pid)) {
        events("exec.init-tail-nginx.phpp success to stop daemon...");
        if ($GLOBALS["OUTPUT"]) {
            echo "Stopping......: " . date("H:i:s") . " [INIT]: nginx-tail, success\n";
        }
    } else {
        events("exec.init-tail-nginx.php failed to stop daemon...");
        if ($GLOBALS["OUTPUT"]) {
            echo "Stopping......: " . date("H:i:s") . " [INIT]: nginx-tail, failed\n";
        }
    }
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:67,代码来源:exec.init-tail-nginx.php

示例11: MultiplesInstances_stop

function MultiplesInstances_stop($hostname)
{
    $unix = new unix();
    $pid = MultiplesInstancesPID($hostname);
    if (!$unix->process_exists($pid)) {
        echo "{$GLOBALS["deflog_sstop"]} {$hostname} already stopped\n";
        return;
    }
    echo "{$GLOBALS["deflog_sstop"]} {$hostname} stopping pid {$pid}\n";
    unix_system_kill($pid);
    for ($i = 0; $i < 20; $i++) {
        $pid = MultiplesInstancesPID($hostname);
        if (!$unix->process_exists($pid)) {
            echo "{$GLOBALS["deflog_sstop"]} {$hostname} stopped\n";
            break;
        }
        echo "{$GLOBALS["deflog_sstop"]} {$hostname} waiting pid {$pid}\n";
        if ($unix->process_exists($pid)) {
            unix_system_kill_force($pid);
            sleep(1);
            continue;
        }
        break;
    }
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:25,代码来源:exec.milter-greylist.php

示例12: GetInstances

function GetInstances()
{
    $unix = new unix();
    $pidsARR = array();
    $kill = $unix->find_program("kill");
    $pgrep = $unix->find_program("pgrep");
    exec("{$pgrep} -l -f \"python.*?tespeed\\.py\" 2>&1", $results);
    while (list($index, $line) = each($results)) {
        if (!preg_match("#([0-9]+)\\s+(.*?)#", $line, $re)) {
            continue;
        }
        $pid = $re[1];
        $cmdline = trim($re[2]);
        if (preg_match("#^sh\\s+#", $cmdline)) {
            continue;
        }
        $time = $unix->PROCCESS_TIME_MIN($pid);
        if ($time > 15) {
            unix_system_kill_force($pid);
            continue;
        }
        $pidsARR[$pid] = true;
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "-> " . count($pidsARR) . " instances..\n";
    }
    return count($pidsARR);
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:28,代码来源:exec.testspeed.php

示例13: stop

function stop($aspid = false)
{
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    if (!$aspid) {
        $pid = $unix->get_pid_from_file($pidfile);
        if ($unix->process_exists($pid, basename(__FILE__))) {
            $time = $unix->PROCCESS_TIME_MIN($pid);
            if ($GLOBALS["OUTPUT"]) {
                echo "Stopping......: " . date("H:i:s") . " [INIT]: Already task running PID {$pid} since {$time}mn\n";
            }
            return;
        }
    }
    @file_put_contents($pidfile, getmypid());
    $pid = ZARAFA_SEARCH_PID();
    if (!$unix->process_exists($pid)) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} already stopped...\n";
        }
        return;
    }
    if (is_file("/tmp/zarafa-upgrade-lock")) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} database upgrade is taking place.\n";
        }
        if ($GLOBALS["OUTPUT"]) {
            echo "Stopping......: " . date("H:i:s") . " [INIT]: Do not stop this process bacause it may render your database unusable..\n";
        }
        return;
    }
    $time = $unix->PROCCESS_TIME_MIN($pid);
    if ($GLOBALS["OUTPUT"]) {
        echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} Daemon with a ttl of {$time}mn\n";
    }
    $kill = $unix->find_program("kill");
    if ($GLOBALS["OUTPUT"]) {
        echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} killing smoothly PID {$pid}...\n";
    }
    unix_system_kill($pid);
    sleep(1);
    for ($i = 1; $i < 5; $i++) {
        $pid = ZARAFA_SEARCH_PID();
        if (!$unix->process_exists($pid)) {
            if ($GLOBALS["OUTPUT"]) {
                echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} pid {$pid} successfully stopped ...\n";
            }
            break;
        }
        if ($GLOBALS["OUTPUT"]) {
            echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} wait pid {$pid} {$i}/5\n";
        }
        sleep(1);
    }
    $pid = ZARAFA_SEARCH_PID();
    if ($unix->process_exists($pid)) {
        unix_system_kill_force($pid);
        sleep(1);
        if ($GLOBALS["OUTPUT"]) {
            echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} force killing {$pid}...\n";
        }
        for ($i = 1; $i < 5; $i++) {
            $pid = ZARAFA_SEARCH_PID();
            if (!$unix->process_exists($pid)) {
                if ($GLOBALS["OUTPUT"]) {
                    echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} pid {$pid} successfully stopped ...\n";
                }
                break;
            }
            unix_system_kill_force($pid);
            sleep(1);
        }
    }
    if (!$unix->process_exists($pid)) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} daemon success...\n";
        }
        return;
    }
    if ($GLOBALS["OUTPUT"]) {
        echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} daemon failed...\n";
    }
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:83,代码来源:exec.zarafa-search.php

示例14: xstart

function xstart()
{
    $unix = new unix();
    $TimeFile = "/etc/artica-postfix/pids/exec.squidcache.php.time";
    $PidFile = "/etc/artica-postfix/pids/exec.squidcache.php.pid";
    $Pid = $unix->get_pid_from_file($PidFile);
    if ($unix->process_exists($Pid)) {
        $pidtime = $unix->PROCCESS_TIME_MIN($Pid);
        if ($pidtime > 29) {
            events("Max execution time reached 30Mn for PID {$Pid} Kill it...", 0, 2, __LINE__);
            unix_system_kill_force($Pid);
            die;
        }
        events("Already running PID {$Pid} since {$pidtime}Mn", 0, 2, __LINE__);
        return;
    }
    @file_put_contents($PidFile, getmypid());
    $pids = $unix->PIDOF_PATTERN_ALL(basename(__FILE__));
    if (count($pids) > 3) {
        events("Too many instances " . count($pids) . " dying", 0, 1, __LINE__);
        $mypid = getmypid();
        while (list($pid, $ligne) = each($pids)) {
            if ($pid == $mypid) {
                continue;
            }
            events("Killing {$pid}");
            unix_system_kill_force($pid);
        }
    }
    $pids = $unix->PIDOF_PATTERN_ALL(basename(__FILE__));
    if (count($pids) > 3) {
        events("Too many instances " . count($pids) . " dying", 0, 2, __LINE__);
        die;
    }
    @unlink($TimeFile);
    @file_put_contents($TimeFile, time());
    $sock = new sockets();
    $GLOBALS["HyperCacheStoragePath"] = $sock->GET_INFO("HyperCacheStoragePath");
    if ($GLOBALS["HyperCacheStoragePath"] == null) {
        $GLOBALS["HyperCacheStoragePath"] = "/home/artica/proxy-cache";
    }
    @chown("/usr/share/squid3", "squid");
    @chgrp("/usr/share/squid3", "squid");
    HyperCacheMirror();
    if ($GLOBALS["HYPER_CACHE_VERBOSE"]) {
        events("Storage path: {$GLOBALS["HyperCacheStoragePath"]}", 0, 2, __LINE__);
        events("Scanning /usr/share/squid3", 0, 2, __LINE__);
    }
    $f = $unix->DirFiles("/usr/share/squid3", "HyperCacheQueue-.+?-([0-9]+)\\.db\$");
    $GLOBALS["SIZE_DOWNLOADED"] = 0;
    $GLOBALS["HITS"] = 0;
    while (list($num, $file) = each($f)) {
        if ($GLOBALS["HYPER_CACHE_VERBOSE"]) {
            events("Found database: {$file}", 0, 2, __LINE__);
        }
        if (!preg_match("#^HyperCacheQueue-.+?-([0-9]+)\\.db\$#", $file, $re)) {
            continue;
        }
        if (preg_match("#HyperCacheQueue-dropbox\\.com#", $file)) {
            continue;
        }
        $ID = $re[1];
        HyperCacheScanDBFile("/usr/share/squid3/{$file}", $ID);
    }
    if ($GLOBALS["SIZE_DOWNLOADED"] > 0) {
        $size = FormatBytes($GLOBALS["SIZE_DOWNLOADED"] / 1024);
        $hits = $GLOBALS["HITS"];
        events("{$size} downloaded -  {$hits} requests", $ID, 2, __LINE__);
        squid_admin_enforce(2, "{$size} downloaded and store {$hits} requests", null, __FILE__, __LINE__);
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "xstart ---> DeleteRules\n";
    }
    DeleteRules();
    if ($GLOBALS["VERBOSE"]) {
        echo "xstart ---> GetRulesSizes\n";
    }
    GetRulesSizes();
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:79,代码来源:exec.squidcache.php

示例15: stop

function stop()
{
    $SERV_NAME = $GLOBALS["SERV_NAME"];
    $unix = new unix();
    $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 "Stopping......: " . date("H:i:s") . " [INIT]:{$SERV_NAME} Already task running PID {$pid} since {$time}mn\n";
        }
        return;
    }
    @file_put_contents($pidfile, getmypid());
    $pid = RSYNC_PID();
    if (!$unix->process_exists($pid)) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Stopping......: " . date("H:i:s") . " [INIT]: {$SERV_NAME} already stopped...\n";
        }
        return;
    }
    $time = $unix->PROCCESS_TIME_MIN($pid);
    if ($GLOBALS["OUTPUT"]) {
        echo "Stopping......: " . date("H:i:s") . " [INIT]: {$SERV_NAME} with a ttl of {$time}mn\n";
    }
    $MirrorDebianDir = $GLOBALS["CLASS_SOCKETS"]->GET_INFO("MirrorDebianDir");
    if ($MirrorDebianDir == null) {
        $MirrorDebianDir = "/home/mirrors/Debian";
    }
    if ($GLOBALS["OUTPUT"]) {
        echo "Stopping......: " . date("H:i:s") . " [INIT]: {$SERV_NAME} with a mirror located in \"{$MirrorDebianDir}\"\n";
    }
    $kill = $unix->find_program("kill");
    for ($i = 0; $i < 10; $i++) {
        $pid = RSYNC_PID();
        if ($unix->process_exists($pid)) {
            if ($GLOBALS["OUTPUT"]) {
                echo "Stopping......: " . date("H:i:s") . " [INIT]: {$SERV_NAME} kill pid {$pid}..\n";
            }
            unix_system_kill_force($pid);
        } else {
            break;
        }
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$SERV_NAME} wait {$i}/10\n";
        }
        sleep(1);
    }
    $pid = RSYNC_PID();
    if (!$unix->process_exists($pid)) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Stopping......: " . date("H:i:s") . " [INIT]: {$SERV_NAME} success...\n";
        }
        return;
    }
    if ($GLOBALS["OUTPUT"]) {
        echo "Stopping......: " . date("H:i:s") . " [INIT]: {$SERV_NAME} Failed...\n";
    }
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:59,代码来源:exec.debian.mirror.php


注:本文中的unix_system_kill_force函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。