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


PHP Process类代码示例

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


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

示例1: min

    /**
     * Insert a new process.
     * @param $processType integer one of the PROCESS_TYPE_* constants
     * @param $maxParallelism integer the max. number
     *  of parallel processes allowed for the given
     *  process type.
     * @return Process the new process instance, boolean
     *  false if there are too many parallel processes.
     */
    function &insertObject($processType, $maxParallelism)
    {
        // Free processing slots occupied by zombie processes.
        $this->deleteZombies();
        // Cap the parallelism to the max. parallelism.
        $maxParallelism = min($maxParallelism, PROCESS_MAX_PARALLELISM);
        // Check whether we're allowed to spawn another process.
        $currentParallelism = $this->getNumberOfObjectsByProcessType($processType);
        if ($currentParallelism >= $maxParallelism) {
            $falseVar = false;
            return $falseVar;
        }
        // We create a process instance from the given data.
        $process = new Process();
        $process->setProcessType($processType);
        // Generate a new process ID. See classdoc for process ID
        // requirements.
        $process->setId(uniqid('', true));
        // Generate the timestamp.
        $process->setTimeStarted(time());
        // Persist the process.
        $this->update(sprintf('INSERT INTO processes
				(process_id, process_type, time_started, obliterated)
				VALUES
				(?, ?, ?, 0)'), array($process->getId(), (int) $process->getProcessType(), (int) $process->getTimeStarted()));
        $process->setObliterated(false);
        return $process;
    }
开发者ID:master3395,项目名称:CBPPlatform,代码行数:37,代码来源:ProcessDAO.inc.php

示例2: process_controller

function process_controller()
{
    //return array('content'=>"ok");
    global $mysqli, $redis, $user, $session, $route, $feed_settings;
    // There are no actions in the input module that can be performed with less than write privileges
    if (!$session['write']) {
        return array('content' => false);
    }
    $result = false;
    require_once "Modules/feed/feed_model.php";
    $feed = new Feed($mysqli, $redis, $feed_settings);
    require_once "Modules/input/input_model.php";
    $input = new Input($mysqli, $redis, $feed);
    require_once "Modules/process/process_model.php";
    $process = new Process($mysqli, $input, $feed, $user->get_timezone($session['userid']));
    if ($route->format == 'html') {
        if ($route->action == 'api') {
            $result = view("Modules/process/Views/process_api.php", array());
        }
    } else {
        if ($route->format == 'json') {
            if ($route->action == "list") {
                $result = $process->get_process_list();
            }
        }
    }
    return array('content' => $result);
}
开发者ID:jpsingleton,项目名称:emoncms,代码行数:28,代码来源:process_controller.php

示例3: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     try {
         $log = new Process();
         $log->name = "get-links";
         $log->status = "running";
         $log->save();
         //Check new links
         Rss::chunk(100, function ($rss) {
             foreach ($rss as $value) {
                 $this->loadRss($value);
                 $value->touch();
             }
         });
         //Remove old links
         $filterDate = new DateTime('now');
         $filterDate->sub(new DateInterval('P1D'));
         Link::where('date', '<', $filterDate)->where('updated_at', '<', $filterDate)->delete();
         $log->status = "finished";
         $log->save();
     } catch (Exception $e) {
         $this->info($url);
         $this->info($e->getMessage());
     }
 }
开发者ID:vmariano,项目名称:shared-links-ranking,代码行数:30,代码来源:LinksCommand.php

示例4: _sendCommand

 /**
  * @param $command
  * @param $string
  */
 protected function _sendCommand($command, $string)
 {
     $process = new Process($command, $this->_globalDictionary);
     $process->write($string);
     $this->_raw = $process->read();
     $process->close();
 }
开发者ID:indynagpal,项目名称:MateCat,代码行数:11,代码来源:HunspellShell.php

示例5: check_job_servers

 function check_job_servers()
 {
     //loop schemas
     foreach (Doo::db()->find('Schemata') as $s) {
         $schema_id = $s->id;
         //enabled config with PID
         foreach (Doo::db()->find('GearmanJobServers', array('where' => 'local = 1 AND enabled = 1 AND schema_id = ' . $schema_id)) as $js) {
             if (!empty($js->pid)) {
                 //init
                 $p = new Process();
                 $p->setPid($js->pid);
                 //check status
                 if ($p->status()) {
                     continue;
                 }
             }
             //let start
             $js->pid = $this->start_local_job_server($js->id, $js->port, $s->id);
             $js->update();
         }
         //disabled config
         foreach (Doo::db()->find('GearmanJobServers', array('where' => 'local = 1 AND enabled = 0 AND pid IS NOT NULL AND schema_id = ' . $schema_id)) as $js) {
             //stop
             $p = new Process();
             $p->setPid($js->pid);
             $p->stop();
             $js->pid = null;
             $js->update(array('setnulls' => true));
         }
     }
 }
开发者ID:garv347,项目名称:swanhart-tools,代码行数:31,代码来源:GearmanJobServerCLIController.php

示例6: execute

 /**
  * add a process
  *
  * @param Process $process
  * @param null|string $name process name
  * @return int
  */
 public function execute(Process $process, $name = null)
 {
     if (!is_null($name)) {
         $process->name($name);
     }
     $process->start();
     return array_push($this->processes, $process);
 }
开发者ID:asuper114,项目名称:simple-fork-php,代码行数:15,代码来源:Pool.php

示例7: testRun

 /**
  * Tests Process::run
  */
 public function testRun()
 {
     $cmd = new Cmd('echo 1');
     $process = new Process();
     $process->addCommand($cmd);
     $res = $process->run();
     $this->assertEquals(0, $res->getCode(), 'echo should work everywhere');
 }
开发者ID:todiadiyatmo,项目名称:phpbu,代码行数:11,代码来源:ProcessTest.php

示例8: copy

 /**
  * Copies the specified hook to your repos git hooks directory only if it
  * doesn't already exist!
  * @param  string $hook the hook to copy/symlink
  * @return void
  */
 public function copy($hook)
 {
     if (false === file_exists(self::GIT_HOOKS_PATH . $hook)) {
         // exec('cp ' . __DIR__ . '/../../../../hooks/' . $hook . ' ' . GIT_HOOKS_PATH . $hook);
         $copy = new Process('cp ' . __DIR__ . '/../../../../hooks/' . $hook . ' .git/hooks/' . $hook);
         $copy->run();
     }
 }
开发者ID:GregoryCollett,项目名称:php-git-kit,代码行数:14,代码来源:HookCopier.php

示例9: setUp

 /**
  * Executed once before each test method.
  */
 public function setUp()
 {
     if (self::$InitProcessToRestore === null) {
         self::$InitProcessToRestore = ProcManager::getInstance()->getCurrentProcess();
     }
     $this->fixture_file1_path = USERS_PATH . '/john/' . USERS_FILES_DIR . '/myHomeFile.ext';
     $this->fixture_metafile1_path = USERS_PATH . '/john/' . USERS_METAFILES_DIR . '/' . USERS_FILES_DIR . '/myHomeFile.ext.xml';
     $this->fixture_file2_path = EYEOS_TESTS_TMP_PATH . '/mySysFile.ext';
     $this->fixture_dir1_path = USERS_PATH . '/john/' . USERS_FILES_DIR . '/myHomeDir';
     $this->fixture_dir2_path = EYEOS_TESTS_TMP_PATH . '/mySysDir';
     $this->group = UMManager::getGroupByName(SERVICE_UM_DEFAULTUSERSGROUP);
     if (!self::$AliceCreated) {
         try {
             //create group "wonderland"
             $wonderland = UMManager::getInstance()->getNewGroupInstance();
             $wonderland->setName('wonderland');
             UMManager::getInstance()->createGroup($wonderland);
         } catch (EyeGroupAlreadyExistsException $e) {
         }
         try {
             //create user "alice"
             $alice = UMManager::getInstance()->getNewUserInstance();
             $alice->setName('alice');
             $alice->setPassword('alice', true);
             $alice->setPrimaryGroupId($wonderland->getId());
             UMManager::getInstance()->createUser($alice);
         } catch (EyeUserAlreadyExistsException $e) {
         }
         self::$AliceCreated = true;
     }
     AdvancedPathLib::rmdirs(USERS_PATH . '/john/' . USERS_FILES_DIR, true);
     AdvancedPathLib::rmdirs(USERS_PATH . '/john/' . USERS_METAFILES_DIR, true);
     if (!is_dir(EYEOS_TESTS_TMP_PATH)) {
         mkdir(EYEOS_TESTS_TMP_PATH, 0777, true);
     }
     AdvancedPathLib::rmdirs(EYEOS_TESTS_TMP_PATH, true);
     $this->fixture_file1 = FSI::getFile('home://~john/myHomeFile.ext');
     file_put_contents($this->fixture_file1_path, 'some content');
     $this->fixture_file2 = FSI::getFile('sys:///tests/tmp/mySysFile.ext');
     file_put_contents($this->fixture_file2_path, 'some other content');
     $this->fixture_dir1 = FSI::getFile('home://~john/myHomeDir');
     if (!is_dir($this->fixture_dir1_path)) {
         mkdir($this->fixture_dir1_path);
     }
     $this->fixture_dir2 = FSI::getFile('sys:///tests/tmp/mySysDir');
     if (!is_dir($this->fixture_dir2_path)) {
         mkdir($this->fixture_dir2_path);
     }
     $proc = new Process('example');
     $loginContext = new LoginContext('example', new Subject());
     $loginContext->getSubject()->getPrivateCredentials()->append(new EyeosPasswordCredential('john', 'john'));
     $loginContext->login();
     $proc->setLoginContext($loginContext);
     ProcManager::getInstance()->execute($proc);
     self::$MyProcPid = $proc->getPid();
 }
开发者ID:DavidGarciaCat,项目名称:eyeos,代码行数:59,代码来源:VirtualFileTest.php

示例10: detectProcessorNumberByGrep

 protected function detectProcessorNumberByGrep()
 {
     if (Utils::findBin('grep') && file_exists('/proc/cpuinfo')) {
         $process = new Process('grep -c ^processor /proc/cpuinfo 2>/dev/null');
         $process->run();
         $this->processorNumber = intval($process->getOutput());
         return $this->processorNumber;
     }
     return;
 }
开发者ID:phpbrew,项目名称:phpbrew,代码行数:10,代码来源:Machine.php

示例11: test_save_form

 /** @Decorated */
 public function test_save_form()
 {
     $pro = new Process();
     $pro->setProcessID($this->input->post("ProcessID"));
     $pro->setGroupID($this->input->post("GroupID"));
     $pro->setProcessName($this->input->post("ProcessName"));
     $this->load->model("process_manager");
     $this->process_manager->save($pro);
     //echo "OK";
 }
开发者ID:pollaeng,项目名称:gwt-php-service,代码行数:11,代码来源:app_test.php

示例12: index

 /**
  * getting default list
  *
  * @param string $httpData (opional)
  */
 public function index($httpData)
 {
     if ($this->userUxType == 'SINGLE') {
         $this->indexSingle($httpData);
         return;
     }
     require_once 'classes/model/UsersProperties.php';
     G::LoadClass('process');
     G::LoadClass('case');
     $userProperty = new UsersProperties();
     $process = new Process();
     $case = new Cases();
     G::loadClass('system');
     $sysConf = System::getSystemConfiguration(PATH_CONFIG . 'env.ini');
     //Get ProcessStatistics Info
     $start = 0;
     $limit = '';
     $proData = $process->getAllProcesses($start, $limit);
     $processList = $case->getStartCasesPerType($_SESSION['USER_LOGGED'], 'category');
     $switchLink = $userProperty->getUserLocation($_SESSION['USER_LOGGED']);
     if (!isset($_COOKIE['workspaceSkin'])) {
         if (substr($sysConf['default_skin'], 0, 2) == 'ux') {
             $_SESSION['_defaultUserLocation'] = $switchLink;
             $switchLink = '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . $sysConf['default_skin'] . '/main';
         }
     }
     unset($processList[0]);
     //Get simplified options
     global $G_TMP_MENU;
     $mnu = new Menu();
     $mnu->load('simplified');
     $arrayMnuOption = array();
     $mnuNewCase = array();
     if (!empty($mnu->Options)) {
         foreach ($mnu->Options as $index => $value) {
             $option = array('id' => $mnu->Id[$index], 'url' => $mnu->Options[$index], 'label' => $mnu->Labels[$index], 'icon' => $mnu->Icons[$index], 'class' => $mnu->ElementClass[$index]);
             if ($mnu->Id[$index] != 'S_NEW_CASE') {
                 $arrayMnuOption[] = $option;
             } else {
                 $mnuNewCase = $option;
             }
         }
     }
     $this->setView($this->userUxBaseTemplate . PATH_SEP . 'index');
     $this->setVar('usrUid', $this->userID);
     $this->setVar('userName', $this->userName);
     $this->setVar('processList', $processList);
     $this->setVar('canStartCase', $case->canStartCase($_SESSION['USER_LOGGED']));
     $this->setVar('userUxType', $this->userUxType);
     $this->setVar('clientBrowser', $this->clientBrowser['name']);
     $this->setVar('switchLink', $switchLink);
     $this->setVar('arrayMnuOption', $arrayMnuOption);
     $this->setVar('mnuNewCase', $mnuNewCase);
     $this->render();
 }
开发者ID:ralpheav,项目名称:processmaker,代码行数:60,代码来源:home.php

示例13: processRequest

 public function processRequest(MMapRequest $request, MMapResponse $response)
 {
     $oauth_verifier = null;
     $oauth_token = null;
     if ($request->issetGET('oauth_verifier')) {
         $oauth_verifier = $request->getGET('oauth_verifier');
     }
     if ($request->issetGET('oauth_token')) {
         $oauth_token = $request->getGET('oauth_token');
     }
     if ($oauth_verifier && $oauth_token) {
         $response->getHeaders()->append('Content-type: text/html');
         $body = '<html>
                         <div id="logo_eyeos" style="margin: 0 auto;width:350"> <img src="eyeos/extern/images/logo-eyeos.jpg"/></div>
                         <div style="margin: 0 auto;width:350;text-align:center"><span style="font-family:Verdana;font-size:20px;">Successful authentication.<br>Back to Eyeos.</span></div>
                  </html>';
         $response->getHeaders()->append('Content-Length: ' . strlen($body));
         $response->getHeaders()->append('Accept-Ranges: bytes');
         $response->getHeaders()->append('X-Pad: avoid browser bug');
         $response->getHeaders()->append('Cache-Control: ');
         $response->getHeaders()->append('pragma: ');
         $response->setBody($body);
         try {
             $userRoot = UMManager::getInstance()->getUserByName('root');
         } catch (EyeNoSuchUserException $e) {
             throw new EyeFailedLoginException('Unknown user root"' . '". Cannot proceed to login.', 0, $e);
         }
         $subject = new Subject();
         $loginContext = new LoginContext('eyeos-login', $subject);
         $cred = new EyeosPasswordCredential();
         $cred->setUsername('root');
         $cred->setPassword($userRoot->getPassword(), false);
         $subject->getPrivateCredentials()->append($cred);
         $loginContext->login();
         Kernel::enterSystemMode();
         $appProcess = new Process('stacksync');
         $appProcess->setPid('31338');
         $mem = MemoryManager::getInstance();
         $processTable = $mem->get('processTable', array());
         $processTable[31338] = $appProcess;
         $mem->set('processTable', $processTable);
         $appProcess->setLoginContext($loginContext);
         ProcManager::getInstance()->setCurrentProcess($appProcess);
         kernel::exitSystemMode();
         $token = new stdClass();
         $token->oauth_verifier = $oauth_verifier;
         $token->oauth_token = $oauth_token;
         $group = UMManager::getInstance()->getGroupByName('users');
         $users = UMManager::getInstance()->getAllUsersFromGroup($group);
         foreach ($users as $user) {
             $NetSyncMessage = new NetSyncMessage('cloud', 'token', $user->getId(), $token);
             NetSyncController::getInstance()->send($NetSyncMessage);
         }
     }
 }
开发者ID:sebasalons,项目名称:eyeos-u1db,代码行数:55,代码来源:MMapStacksync.php

示例14: save_object

 /** @Decorated */
 public function save_object($object_name)
 {
     if ($object_name == "Process") {
         $pro = new Process();
         $pro->setProcessID($this->input->post("ProcessID"));
         $pro->setGroupID($this->input->post("GroupID"));
         $pro->setProcessName($this->input->post("ProcessName"));
         $this->load->model("process_manager");
         $this->process_manager->save($pro);
     }
     $this->output->set_output("Save " . $object_name . " successfully!");
 }
开发者ID:pollaeng,项目名称:gwt-php-service,代码行数:13,代码来源:admin_panel.php

示例15: setUp

 public function setUp()
 {
     if (self::$InitProcessToRestore === null) {
         self::$InitProcessToRestore = ProcManager::getInstance()->getCurrentProcess();
     }
     $this->config = new XMLAuthConfiguration(SYSTEM_CONF_PATH . '/' . SERVICES_DIR . '/' . SERVICE_UM_DIR . '/' . SERVICE_UM_AUTHCONFIGURATIONS_DIR . '/eyeos_default.xml');
     $this->loginContext = new LoginContext('eyeos-login', new Subject(), $this->config);
     $this->loginContext->getSubject()->getPrivateCredentials()->append(new EyeosPasswordCredential('john', 'john'));
     $this->loginContext->login();
     $proc = new Process('init');
     $proc->setLoginContext($this->loginContext);
     ProcManager::getInstance()->execute($proc);
     self::$MyProcPid = $proc->getPid();
 }
开发者ID:DavidGarciaCat,项目名称:eyeos,代码行数:14,代码来源:ProcessTest.php


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