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


PHP Daemon::date_period_text方法代码示例

本文整理汇总了PHP中Daemon::date_period_text方法的典型用法代码示例。如果您正苦于以下问题:PHP Daemon::date_period_text方法的具体用法?PHP Daemon::date_period_text怎么用?PHP Daemon::date_period_text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Daemon的用法示例。


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

示例1: run

    /**
     * Called when request iterated.
     * @return integer Status.
     */
    public function run()
    {
        $stime = microtime(TRUE);
        $this->header('Content-Type: text/html; charset=utf-8');
        ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Server status.</title> 
</head> 
<body>
<br />Uptime: <b><?php 
        echo Daemon::date_period_text(Daemon::$startTime, time());
        ?>
</b>
<br /><br /><b>State of workers:</b><?php 
        $stat = Daemon::getStateOfWorkers();
        ?>
<br />Idle: <?php 
        echo $stat['idle'];
        ?>
<br />Busy: <?php 
        echo $stat['busy'];
        ?>
<br />Total alive: <?php 
        echo $stat['alive'];
        ?>
<br />Shutdown: <?php 
        echo $stat['shutdown'];
        ?>
<br />Pre-init: <?php 
        echo $stat['preinit'];
        ?>
<br />Wait-init: <?php 
        echo $stat['waitinit'];
        ?>
<br />Init: <?php 
        echo $stat['init'];
        ?>
<br />
<br />Request took: <?php 
        printf('%f', round(microtime(TRUE) - $stime, 6));
        ?>
</body>
</html>
<?php 
        return;
    }
开发者ID:J3FF3,项目名称:phpdaemon,代码行数:53,代码来源:ServerStatus.php

示例2: init


//.........这里部分代码省略.........
         } elseif ($sg['gid'] != posix_getgid() && posix_getuid() != 0) {
             Daemon::log('You must have the root privileges to change group.');
             $error = TRUE;
         }
     }
     if (isset(Daemon::$config->user->value) && is_callable('posix_getuid')) {
         if (($su = posix_getpwnam(Daemon::$config->user->value)) === FALSE) {
             Daemon::log('Unexisting user \'' . Daemon::$config->user->value . '\', user not found. You have to replace config-variable \'user\' with existing username.');
             $error = TRUE;
         } elseif ($su['uid'] != posix_getuid() && posix_getuid() != 0) {
             Daemon::log('You must have the root privileges to change user.');
             $error = TRUE;
         }
     }
     if (isset(Daemon::$config->minspareworkers->value) && isset(Daemon::$config->maxspareworkers->value)) {
         if (Daemon::$config->minspareworkers->value > Daemon::$config->maxspareworkers->value) {
             Daemon::log('\'minspareworkers\' cannot be greater than \'maxspareworkers\'.');
             $error = TRUE;
         }
     }
     if (isset(Daemon::$config->minworkers->value) && isset(Daemon::$config->maxworkers->value)) {
         if (Daemon::$config->minworkers->value > Daemon::$config->maxworkers->value) {
             Daemon::$config->minworkers->value = Daemon::$config->maxworkers->value;
         }
     }
     if ($runmode == 'start') {
         if ($error === FALSE) {
             Daemon_Bootstrap::start();
         }
     } elseif ($runmode == 'status' || $runmode == 'fullstatus') {
         $status = Daemon_Bootstrap::$pid && posix_kill(Daemon_Bootstrap::$pid, SIGTTIN);
         echo '[STATUS] phpDaemon ' . Daemon::$version . ' is ' . ($status ? 'running' : 'NOT running') . ' (' . Daemon::$config->pidfile->value . ").\n";
         if ($status && $runmode == 'fullstatus') {
             echo 'Uptime: ' . Daemon::date_period_text(filemtime(Daemon::$config->pidfile->value), time()) . "\n";
             Daemon::$shm_wstate = Daemon::shmop_open(Daemon::$config->pidfile->value, 0, 'wstate', FALSE);
             $stat = Daemon::getStateOfWorkers();
             echo "State of workers:\n";
             echo "\tTotal: " . $stat['alive'] . "\n";
             echo "\tIdle: " . $stat['idle'] . "\n";
             echo "\tBusy: " . $stat['busy'] . "\n";
             echo "\tShutdown: " . $stat['shutdown'] . "\n";
             echo "\tPre-init: " . $stat['preinit'] . "\n";
             echo "\tWait-init: " . $stat['waitinit'] . "\n";
             echo "\tInit: " . $stat['init'] . "\n";
         }
         echo "\n";
     } elseif ($runmode == 'update') {
         if (!Daemon_Bootstrap::$pid || !posix_kill(Daemon_Bootstrap::$pid, SIGHUP)) {
             echo '[UPDATE] ERROR. It seems that phpDaemon is not running' . (Daemon_Bootstrap::$pid ? ' (PID ' . Daemon_Bootstrap::$pid . ')' : '') . ".\n";
         }
     } elseif ($runmode == 'reopenlog') {
         if (!Daemon_Bootstrap::$pid || !posix_kill(Daemon_Bootstrap::$pid, SIGUSR1)) {
             echo '[REOPEN-LOG] ERROR. It seems that phpDaemon is not running' . (Daemon_Bootstrap::$pid ? ' (PID ' . Daemon_Bootstrap::$pid . ')' : '') . ".\n";
         }
     } elseif ($runmode == 'reload') {
         if (!Daemon_Bootstrap::$pid || !posix_kill(Daemon_Bootstrap::$pid, SIGUSR2)) {
             echo '[RELOAD] ERROR. It seems that phpDaemon is not running' . (Daemon_Bootstrap::$pid ? ' (PID ' . Daemon_Bootstrap::$pid . ')' : '') . ".\n";
         }
     } elseif ($runmode == 'restart') {
         if ($error === FALSE) {
             Daemon_Bootstrap::stop(2);
             Daemon_Bootstrap::start();
         }
     } elseif ($runmode == 'hardrestart') {
         Daemon_Bootstrap::stop(3);
         Daemon_Bootstrap::start();
开发者ID:J3FF3,项目名称:phpdaemon,代码行数:67,代码来源:Daemon_Bootstrap.php

示例3: init


//.........这里部分代码省略.........
         } elseif ($sg['gid'] != posix_getgid() && posix_getuid() != 0) {
             Daemon::log('You must have the root privileges to change group.');
             $error = TRUE;
         }
     }
     if (isset(Daemon::$settings['user']) && is_callable('posix_getuid')) {
         if (($su = posix_getpwnam(Daemon::$settings['user'])) === FALSE) {
             Daemon::log('Unexisting user \'' . Daemon::$settings['user'] . '\', user not found. You have to replace config-variable \'user\' with existing username.');
             $error = TRUE;
         } elseif ($su['uid'] != posix_getuid() && posix_getuid() != 0) {
             Daemon::log('You must have the root privileges to change user.');
             $error = TRUE;
         }
     }
     if (isset(Daemon::$settings['minspareworkers']) && isset(Daemon::$settings['maxspareworkers'])) {
         if (Daemon::$settings['minspareworkers'] > Daemon::$settings['maxspareworkers']) {
             Daemon::log('\'minspareworkers\' cannot be greater than \'maxspareworkers\'.');
             $error = TRUE;
         }
     }
     if (isset(Daemon::$settings['minworkers']) && isset(Daemon::$settings['maxworkers'])) {
         if (Daemon::$settings['minworkers'] > Daemon::$settings['maxworkers']) {
             Daemon::$settings['maxworkers'] = Daemon::$settings['minworkers'];
         }
     }
     if ($runmode == 'start') {
         if ($error === FALSE) {
             Daemon_Bootstrap::start();
         }
     } elseif ($runmode == 'status' or $runmode == 'fullstatus') {
         $status = Daemon_Bootstrap::$pid && posix_kill(Daemon_Bootstrap::$pid, SIGTTIN);
         echo '[STATUS] phpDaemon ' . Daemon::$version . ' is ' . ($status ? 'running' : 'NOT running') . ' (' . Daemon_Bootstrap::$pidfile . ").\n";
         if ($status && $runmode == 'fullstatus') {
             echo 'Uptime: ' . Daemon::date_period_text(filemtime(Daemon_Bootstrap::$pidfile), time()) . "\n";
             Daemon::$shm_wstate = Daemon::shmop_open(Daemon::$settings['ipcwstate'], 0, 'wstate', FALSE);
             $stat = Daemon::getStateOfWorkers();
             echo "State of workers:\n";
             echo "\tTotal: " . $stat['alive'] . "\n";
             echo "\tIdle: " . $stat['idle'] . "\n";
             echo "\tBusy: " . $stat['busy'] . "\n";
             echo "\tShutdown: " . $stat['shutdown'] . "\n";
             echo "\tPre-init: " . $stat['preinit'] . "\n";
             echo "\tWait-init: " . $stat['waitinit'] . "\n";
             echo "\tInit: " . $stat['init'] . "\n";
         }
         echo "\n";
     } elseif ($runmode == 'update') {
         if (!Daemon_Bootstrap::$pid || !posix_kill(Daemon_Bootstrap::$pid, SIGHUP)) {
             echo '[UPDATE] ERROR. It seems that phpDaemon is not running' . (Daemon_Bootstrap::$pid ? ' (PID ' . Daemon_Bootstrap::$pid . ')' : '') . ".\n";
         }
     } elseif ($runmode == 'reopenlog') {
         if (!Daemon_Bootstrap::$pid || !posix_kill(Daemon_Bootstrap::$pid, SIGUSR1)) {
             echo '[REOPEN-LOG] ERROR. It seems that phpDaemon is not running' . (Daemon_Bootstrap::$pid ? ' (PID ' . Daemon_Bootstrap::$pid . ')' : '') . ".\n";
         }
     } elseif ($runmode == 'reload') {
         if (!Daemon_Bootstrap::$pid || !posix_kill(Daemon_Bootstrap::$pid, SIGUSR2)) {
             echo '[RELOAD] ERROR. It seems that phpDaemon is not running' . (Daemon_Bootstrap::$pid ? ' (PID ' . Daemon_Bootstrap::$pid . ')' : '') . ".\n";
         }
     } elseif ($runmode == 'restart') {
         Daemon_Bootstrap::stop(2);
         Daemon_Bootstrap::start();
     } elseif ($runmode == 'hardrestart') {
         Daemon_Bootstrap::stop(3);
         Daemon_Bootstrap::start();
     } elseif ($runmode == 'configtest') {
         $term = new Terminal();
开发者ID:svcorp77,项目名称:phpdaemon,代码行数:67,代码来源:Daemon_Bootstrap.class.php


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