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


PHP proc_nice函数代码示例

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


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

示例1: run

 /**
  * мастерский рабочий цикл
  */
 public function run()
 {
     try {
         static::log('starting master (PID ' . posix_getpid() . ')....');
         //задаем приоритет процесса в ОС
         proc_nice($this->priority);
         //включаем сборщик циклических зависимостей
         gc_enable();
         //выполняем функцию приложения до рабочего цикла
         call_user_func([$this->appl, 'baseOnRun']);
         //самый главный цикл
         while (TRUE) {
             if (TRUE === call_user_func([$this->appl, 'baseRun'])) {
                 //прекращаем цикл
                 break;
             }
             //ожидаем заданное время для получения сигнала операционной системы
             $this->sigwait();
             //если сигнал был получен, вызываем связанную с ним функцию
             pcntl_signal_dispatch();
         }
     } catch (\Exception $e) {
         $this->shutdown();
     }
 }
开发者ID:yutas,项目名称:phpdaemon,代码行数:28,代码来源:Master.php

示例2: archive_stream_zip_directory

function archive_stream_zip_directory($root, $archive = 'archive.zip')
{
    ini_set('display_errors', '1');
    ini_set('display_startup_errors', '1');
    date_default_timezone_set('UTC');
    if (!class_exists('RecursiveIteratorIterator') || !function_exists('gzdeflate')) {
        return 1;
    }
    if (!file_exists($root)) {
        return 2;
    }
    if (function_exists('proc_nice')) {
        proc_nice(19);
    }
    $files = array();
    $added = array();
    $objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($root), RecursiveIteratorIterator::SELF_FIRST);
    $zip = new ArchiveStream_Zip($archive);
    foreach ($objects as $name => $object) {
        // http://php.net/manual/en/splfileinfo.getbasename.php
        $basename = $object->getBasename();
        if ('.' === $basename || '..' === $basename || $object->isDir()) {
            continue;
        }
        $zip->add_file_from_path(ltrim($name, '/'), $name);
        //DBG echo $name.'<br>';
        $added[] = $name;
    }
    $zip->finish();
    if (function_exists('proc_nice')) {
        proc_nice(0);
    }
    return $added;
}
开发者ID:vrkansagara,项目名称:wordpress-plugin-construction,代码行数:34,代码来源:stream-archive.php

示例3: __construct

 public function __construct(SiteApplication $app)
 {
     $this->app = $app;
     set_time_limit(30000);
     ini_set('memory_limit', -1);
     proc_nice(19);
 }
开发者ID:gauthierm,项目名称:pinhole,代码行数:7,代码来源:PinholePhotoProcessor.php

示例4: run

 public function run()
 {
     proc_nice(Daemon::$settings['masterpriority']);
     gc_enable();
     register_shutdown_function(array($this, 'onShutdown'));
     $this->collections = array('workers' => new threadCollection());
     Thread::setproctitle(Daemon::$runName . ': master process' . (Daemon::$settings['pidfile'] !== Daemon::$settings['defaultpidfile'] ? ' (' . Daemon::$settings['pidfile'] . ')' : ''));
     Daemon::$appResolver = (require Daemon::$settings['path']);
     Daemon::$appResolver->preloadPrivileged();
     $this->spawnWorkers(min(Daemon::$settings['startworkers'], Daemon::$settings['maxworkers']));
     $mpmLast = time();
     $autoReloadLast = time();
     while (TRUE) {
         pcntl_signal_dispatch();
         $this->sigwait(1, 0);
         clearstatcache();
         if (Daemon::$logpointerpath !== Daemon::parseStoragepath(Daemon::$settings['logstorage'])) {
             $this->sigusr1();
         }
         $c = 1;
         if (time() > $mpmLast + Daemon::$parsedSettings['mpmdelay']) {
             $mpmLast = time();
             ++$c;
             if ($c > 0xfffff) {
                 $c = 0;
             }
             if ($c % 10 == 0) {
                 $this->collections['workers']->removeTerminated(TRUE);
                 gc_collect_cycles();
             } else {
                 $this->collections['workers']->removeTerminated();
             }
             if (isset(Daemon::$settings['mpm']) && is_callable($c = Daemon::$settings['mpm'])) {
                 call_user_func($c);
             } else {
                 $state = Daemon::getStateOfWorkers($this);
                 if ($state) {
                     $n = max(min(Daemon::$settings['minspareworkers'] - $state['idle'], Daemon::$settings['maxworkers'] - $state['alive']), Daemon::$settings['minworkers'] - $state['alive']);
                     if ($n > 0) {
                         Daemon::log('Spawning ' . $n . ' worker(s).');
                         $this->spawnWorkers($n);
                     }
                     $n = min($state['idle'] - Daemon::$settings['maxspareworkers'], $state['alive'] - Daemon::$settings['minworkers']);
                     if ($n > 0) {
                         Daemon::log('Stopping ' . $n . ' worker(s).');
                         $this->stopWorkers($n);
                     }
                 }
             }
         }
     }
 }
开发者ID:svcorp77,项目名称:phpdaemon,代码行数:52,代码来源:Daemon_MasterThread.class.php

示例5: cron

 /**
  * cron
  *
  * function called to create a cron
  *
  * @access	public
  * @param	string $app_name name of application to cron
  * @param	mixed $params null, or array of params for cron creation
  */
 function cron($app_name, $params = '')
 {
     // be very nice to other processes
     if (php_sapi_name() == 'cli') {
         proc_nice(19);
     }
     $this->_startTimer();
     $this->_app_name = $app_name;
     $this->_lock_file_name = '/web/temp/' . $app_name . '.lock';
     set_time_limit(0);
     $this->_stdin = fopen('php://stdin', 'r');
     $this->log_file = '/web/temp/' . $app_name . '.log';
     parse_str($params, $params);
     foreach ($params as $param => $value) {
         $this->{$param} = $value;
     }
     //end foreach
 }
开发者ID:AholibamaSI,项目名称:plymouth-webapp,代码行数:27,代码来源:cron.class.php

示例6: run

 /**
  * @method run
  * @desc Runtime of Child process.
  * @return void
  */
 public function run()
 {
     try {
         static::log('starting child (PID ' . posix_getpid() . ')....', Logger::L_TRACE);
         proc_nice($this->priority);
         gc_enable();
         $this->start_time = microtime(true);
         call_user_func([$this->appl, 'baseOnRun']);
         while (TRUE) {
             if (TRUE === call_user_func([$this->appl, 'baseRun']) || $this->isItTimeToDie()) {
                 break;
             }
             //ожидаем заданное время для получения сигнала операционной системы
             $this->sigwait(Config::get('Daemon.child_sigwait'));
             //если сигнал был получен, вызываем связанную с ним функцию
             pcntl_signal_dispatch();
         }
     } catch (\Exception $e) {
         $this->shutdown();
     }
 }
开发者ID:yutas,项目名称:phpdaemon,代码行数:26,代码来源:Child.php

示例7: adjustPriority

 /**
  * Call proc_nice with passed value if available on this platform.
  *
  * @param int Priorty adjustment to be made.
  * @return boolean True if successful.
  *
  * @see options['adjustPriority']
  * @see http://us3.php.net/manual/en/function.proc-nice.php
  **/
 public function adjustPriority($adjBy)
 {
     if (!function_exists('proc_nice')) {
         return;
     }
     return proc_nice($adjBy);
 }
开发者ID:apinstein,项目名称:jqjobs,代码行数:16,代码来源:JQWorker.php

示例8: nice

 /**
  * Set "nice" value for the process
  *
  * @param  [type] $nice Nice level 0 .. 20
  * @return null
  */
 function nice($nice)
 {
     if (function_exists('proc_nice')) {
         proc_nice($this->process, $nice);
     }
 }
开发者ID:easyconn,项目名称:atk4,代码行数:12,代码来源:ProcessIO.php

示例9: run

 public function run()
 {
     proc_nice(Daemon::$settings['workerpriority']);
     Daemon::$worker = $this;
     $this->microsleep = Daemon::$settings['microsleep'];
     $this->autoReloadLast = time();
     $this->reloadDelay = Daemon::$parsedSettings['mpmdelay'] + 2;
     $this->setStatus(4);
     Thread::setproctitle(Daemon::$runName . ': worker process' . (Daemon::$settings['pidfile'] !== Daemon::$settings['defaultpidfile'] ? ' (' . Daemon::$settings['pidfile'] . ')' : ''));
     register_shutdown_function(array($this, 'shutdown'));
     if (Daemon::$settings['autogc'] > 0) {
         gc_enable();
     } else {
         gc_disable();
     }
     if (isset(Daemon::$settings['group'])) {
         $sg = posix_getgrnam(Daemon::$settings['group']);
     }
     if (isset(Daemon::$settings['user'])) {
         $su = posix_getpwnam(Daemon::$settings['user']);
     }
     if (Daemon::$settings['chroot'] !== '/') {
         if (posix_getuid() != 0) {
             Daemon::log('You must have the root privileges to change root.');
             exit(0);
         } elseif (!chroot(Daemon::$settings['chroot'])) {
             Daemon::log('Couldn\'t change root to \'' . Daemon::$settings['chroot'] . '\'.');
             exit(0);
         }
     }
     if (isset(Daemon::$settings['group'])) {
         if ($sg === FALSE) {
             Daemon::log('Couldn\'t change group to \'' . Daemon::$settings['group'] . '\'. You must replace config-variable \'group\' with existing group.');
             exit(0);
         } elseif ($sg['gid'] != posix_getgid() && !posix_setgid($sg['gid'])) {
             Daemon::log('Couldn\'t change group to \'' . Daemon::$settings['group'] . "'. Error (" . ($errno = posix_get_last_error()) . '): ' . posix_strerror($errno));
             exit(0);
         }
     }
     if (isset(Daemon::$settings['user'])) {
         if ($su === FALSE) {
             Daemon::log('Couldn\'t change user to \'' . Daemon::$settings['user'] . '\', user not found. You must replace config-variable \'user\' with existing username.');
             exit(0);
         } elseif ($su['uid'] != posix_getuid() && !posix_setuid($su['uid'])) {
             Daemon::log('Couldn\'t change user to \'' . Daemon::$settings['user'] . "'. Error (" . ($errno = posix_get_last_error()) . '): ' . posix_strerror($errno));
             exit(0);
         }
     }
     if (Daemon::$settings['cwd'] !== '.') {
         if (!@chdir(Daemon::$settings['cwd'])) {
             Daemon::log('WORKER ' . $this->pid . '] Couldn\'t change directory to \'' . Daemon::$settings['cwd'] . '.');
         }
     }
     $this->setStatus(6);
     $this->eventBase = event_base_new();
     Daemon::$appResolver->preload();
     foreach (Daemon::$appInstances as $app) {
         foreach ($app as $appInstance) {
             if (!$appInstance->ready) {
                 $this->ready = TRUE;
                 $appInstance->onReady();
             }
         }
     }
     $this->setStatus(1);
     $ev = event_new();
     event_set($ev, STDIN, EV_TIMEOUT, function () {
     }, array());
     event_base_set($ev, $this->eventBase);
     $this->timeoutEvent = $ev;
     while (TRUE) {
         pcntl_signal_dispatch();
         if (($s = $this->checkState()) !== TRUE) {
             $this->closeSockets();
             if (sizeof($this->queue) === 0) {
                 return $s;
             }
         }
         event_add($this->timeoutEvent, $this->microsleep);
         event_base_loop($this->eventBase, EVLOOP_ONCE);
         do {
             for ($i = 0, $s = sizeof($this->eventsToAdd); $i < $s; ++$i) {
                 event_add($this->eventsToAdd[$i]);
                 unset($this->eventsToAdd[$i]);
             }
             $this->readPool();
             $processed = $this->runQueue();
         } while ($processed || $this->readPoolState || $this->eventsToAdd);
     }
 }
开发者ID:svcorp77,项目名称:phpdaemon,代码行数:90,代码来源:Daemon_WorkerThread.class.php

示例10: chdir

<?php

chdir('..');
$MIN_DAYS = 2;
require_once 'common.inc';
require_once 'archive.inc';
ignore_user_abort(true);
set_time_limit(3300);
// only allow it to run for 55 minutes
if (function_exists('proc_nice')) {
    proc_nice(19);
}
// bail if we are already running
$lock = Lock("Archive", false, 3600);
if (!isset($lock)) {
    echo "Archive process is already running\n";
    exit(0);
}
if (array_key_exists('archive_days', $settings)) {
    $MIN_DAYS = $settings['archive_days'];
}
$MIN_DAYS = max($MIN_DAYS, 0.1);
$archive_dir = null;
if (array_key_exists('archive_dir', $settings)) {
    $archive_dir = $settings['archive_dir'];
}
$kept = 0;
$archiveCount = 0;
$deleted = 0;
$log = fopen('./cli/archive.log', 'w');
// check the old tests first
开发者ID:lucasRolff,项目名称:webpagetest,代码行数:31,代码来源:archive.php

示例11: dirname

//
//STOP FAKE REGISTER GLOBALS
$fake_register_globals = false;
//
require_once dirname(__FILE__) . "/../../interface/globals.php";
require_once dirname(__FILE__) . "/../reminders.php";
//To improve performance and not freeze the session when running this
// report, turn off session writing. Note that php session variables
// can not be modified after the line below. So, if need to do any php
// session work in the future, then will need to remove this line.
session_write_close();
//Remove time limit, since script can take many minutes
set_time_limit(0);
// Set the "nice" level of the process for these reports. When the "nice" level
// is increased, these cpu intensive reports will have less affect on the performance
// of other server activities, albeit it may negatively impact the performance
// of this report (note this is only applicable for linux).
if (!empty($GLOBALS['pat_rem_clin_nice'])) {
    proc_nice($GLOBALS['pat_rem_clin_nice']);
}
//  Start a report, which will be stored in the report_results sql table..
if (!empty($_POST['execute_report_id']) && !empty($_POST['process_type']) && ($_POST['process_type'] == "process" || $_POST['process_type'] == "process_send")) {
    if ($_POST['process_type'] == "process_send") {
        update_reminders_batch_method('', '', $_POST['execute_report_id'], TRUE);
    } else {
        // $_POST['process_type'] == "process"
        update_reminders_batch_method('', '', $_POST['execute_report_id']);
    }
} else {
    echo "ERROR";
}
开发者ID:katopenzz,项目名称:openemr,代码行数:31,代码来源:execute_pat_reminder.php

示例12: prepareSystemEnv

 /**
  * Setup settings on start.
  * @return void
  */
 protected function prepareSystemEnv()
 {
     register_shutdown_function(function () {
         if ($this->pid != posix_getpid()) {
             return;
         }
         if ($this->shutdown === true) {
             return;
         }
         $this->log('Unexcepted shutdown.');
         $this->shutdown(SIGTERM);
     });
     posix_setsid();
     proc_nice(Daemon::$config->masterpriority->value);
     if (!Daemon::$config->verbosetty->value) {
         fclose(STDIN);
         fclose(STDOUT);
         fclose(STDERR);
     }
     $this->setTitle(Daemon::$runName . ': master process' . (Daemon::$config->pidfile->value !== Daemon::$config->pidfile->defaultValue ? ' (' . Daemon::$config->pidfile->value . ')' : ''));
 }
开发者ID:shamahan,项目名称:phpdaemon,代码行数:25,代码来源:Master.php

示例13: work

 private function work()
 {
     $this->getLogger()->debug("Child {$this->myPid} about to start work");
     if ($this->nice) {
         $this->getLogger()->debug("Child being reniced to {$this->nice}");
         proc_nice($this->nice);
     }
     while ($this->shouldWork) {
         pcntl_signal_dispatch();
         $_SERVER['REQUEST_TIME'] = time();
         $_SERVER['REQUEST_TIME_FLOAT'] = microtime(true);
         if ($this->doWork()) {
             $this->roundsComplete++;
         }
         // If runCount is 0, go indefinitely. Otherwise stop after runCount
         if ($this->runCount && $this->roundsComplete >= $this->runCount) {
             $this->stopWorking();
         }
     }
     $this->getLogger()->info("Child has stopped working and will exit");
     exit;
 }
开发者ID:firehed,项目名称:processmanager,代码行数:22,代码来源:ProcessManager.php

示例14: makeUnfriendlier

 /**
  * At process level increases the niceness of a heavy "thread" making its priority lower. Multiple calls of the method will accumulate and increase the effect.
  * @see \GPhpThread::makeNicer() A method with the opposite effect is GPhpThread::makeNicer().
  * @return bool Returns true on success or false in case of error or lack of privileges.
  */
 protected function makeUnfriendlier()
 {
     // {{{ decreases the priority
     if ($this->amIParent()) {
         return false;
     }
     return proc_nice(1);
 }
开发者ID:zhgzhg,项目名称:gphpthread,代码行数:13,代码来源:GPhpThread.php

示例15: array

<?php

midcom::get('auth')->require_admin_user();
// If we import some other database than Geonames this is the place to tune
// Also, the Geonames dump format may change. See http://download.geonames.org/export/dump/readme.txt
// The current state of this, incl. comments reflects the Geonames format as of 2008-12-15
$fields_map = array('geonameid' => 0, 'name' => 1, 'asciiname' => 2, 'alternatenames' => 3, 'latitude' => 4, 'longitude' => 5, 'featureclass' => 6, 'featurecode' => 7, 'country' => 8, 'cc2' => 9, 'admin1 code' => 10, 'admin2 code' => 11, 'admin3 code' => 12, 'admin4 code' => 13, 'population' => 14, 'elevation' => 15, 'gtopo30' => 16, 'timezone' => 17, 'modification date' => 18);
if (array_key_exists('cities_file_path', $_POST) && file_exists($_POST['cities_file_path'])) {
    $features = explode(',', $_POST['featurecodes_to_import']);
    midcom::get()->disable_limits();
    // this is a potentially very time and resource intensive operation, so let's play nicely:
    if (is_callable('proc_nice')) {
        proc_nice(10);
    }
    while (@ob_end_flush()) {
    }
    $imported_cities = array();
    // Read CSV file
    $cities_created = 0;
    $row = 0;
    $handle = fopen($_POST['cities_file_path'], 'r');
    while ($data = fgetcsv($handle, 1000, "\t")) {
        $row++;
        //if ($row > 1000) { break; }
        if (!isset($data[$fields_map['featurecode']]) || !in_array($data[$fields_map['featurecode']], $features)) {
            continue;
        }
        if ($data[$fields_map['population']] < $_POST['population_to_import']) {
            continue;
        }
        if (strlen($data[$fields_map['country']]) > 2) {
开发者ID:nemein,项目名称:openpsa,代码行数:31,代码来源:import-cities.php


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