• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP proc_nice函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: adjustNiceness

 /**
  * Change parent process priority according to EXTENDER_NICENESS
  *
  */
 public final function adjustNiceness()
 {
     if (defined("EXTENDER_PARENT_NICENESS")) {
         $niceness = proc_nice(EXTENDER_PARENT_NICENESS);
         if ($niceness == false) {
             $this->logger->warning("Unable to set parent process niceness to " . EXTENDER_PARENT_NICENESS);
         }
     }
 }
开发者ID:comodojo,项目名称:extender.framework,代码行数:13,代码来源:Extender.php


示例17: _proc_nice_shutdown_function

 function _proc_nice_shutdown_function()
 {
     // Restore priority
     proc_nice(0);
 }
开发者ID:Artea,项目名称:freebeer,代码行数:5,代码来源:Backport.php


示例18: fclose

fclose($pipes[0]);
fpassthru($pipes[1]);
VS(proc_close($process), 0);
$descriptorspec = array(array("pipe", "r"), array("pipe", "w"), array("file", $errout, "a"));
$process = proc_open('cat', $descriptorspec, $pipes);
VERIFY($process != false);
VERIFY(proc_terminate($process));
// still need to close it, not to leave a zombie behind
proc_close($process);
$process = proc_open('cat', $descriptorspec, $pipes);
VERIFY($process != false);
$ret = proc_get_status($process);
VS($ret['command'], 'cat');
VERIFY($ret['pid'] > 0);
VERIFY($ret['running']);
VERIFY(!$ret['signaled']);
VS($ret['exitcode'], -1);
VS($ret['termsig'], 0);
VS($ret['stopsig'], 0);
proc_close($process);
VERIFY(proc_nice(0));
VS(escapeshellarg("\""), "'\"'");
VS(escapeshellcmd("perl \""), "perl \\\"");
$nullbyte = "echo abc\ncommand";
VS(passthru($nullbyte), null);
VS(system($nullbyte), "");
VS(exec($nullbyte, $nullbyteout), "");
VS($nullbyteout, null);
VS(shell_exec($nullbyte), null);
$process = proc_open($nullbyte, array(), $pipes);
VS($process, false);
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:lwp.php


示例19: var_dump

<?php

echo "*** Test by calling method or function with incorrect numbers of arguments ***\n";
$priority = 1;
$extra_arg = 1;
var_dump(proc_nice($priority, $extra_arg));
var_dump(proc_nice());
开发者ID:badlamer,项目名称:hhvm,代码行数:7,代码来源:proc_nice_error.php


示例20: prepareSystemEnv

 /**
  * Setup settings on start.
  * @return void
  */
 public function prepareSystemEnv()
 {
     register_shutdown_function(array($this, 'onShutdown'));
     proc_nice(Daemon::$config->masterpriority->value);
     $this->setproctitle(Daemon::$runName . ': master process' . (Daemon::$config->pidfile->value !== Daemon::$config->pidfile->defaultValue ? ' (' . Daemon::$config->pidfile->value . ')' : ''));
 }
开发者ID:ruslanchek,项目名称:phpdaemon,代码行数:10,代码来源:Daemon_MasterThread.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP proc_open函数代码示例发布时间:2022-05-15
下一篇:
PHP proc_get_status函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap