示例#1
0
function ProcessPostObjects()
{
    require_once 'PeepAPI/PeepProcessManager.php';
    $ProcessManager = new ProcessManager();
    $ServiceRelayMessages = array();
    $transactionSuccess = 0;
    foreach ($_POST as $key => $value) {
        $PeepRelayMessage = new PeepRelayMessage();
        $value = json_decode(base64_decode($value));
        switch ($key) {
            case 'POSTObjectMethod::GetNewPeepID':
                PublicStaticFunction::WriteLogFile("Call function GetNewPeeID()!");
                $PeepRelayMessage = $value;
                $PeepRelayMessage = $ProcessManager->ProcessPeepTrack($value, 'POSTObjectMethod::GetNewPeepID');
                PublicStaticFunction::WriteLogFile(print_r($PeepRelayMessage, true));
                break;
            case 'POSTObjectMethod::ProcessPeep':
                PublicStaticFunction::WriteLogFile("Call function ProcessPeep()!");
                $PeepRelayMessage = $ProcessManager->ProcessPeepTrack($value, 'POSTObjectMethod::ProcessPeep');
                PublicStaticFunction::WriteLogFile(print_r($PeepRelayMessage, true));
                break;
        }
        if ($key != "APIKey") {
            AssociativeArrayPush($ServiceRelayMessages, $key, $PeepRelayMessage);
        }
        $transactionSuccess = $PeepRelayMessage->OperationSuccess;
        if (!$transactionSuccess && $key != "APIKey") {
            break;
        }
    }
    return $ServiceRelayMessages;
}
示例#2
0
 /**
  * Signals handler function
  *
  * @param integer $signal
  * @final 
  */
 public final function HandleSignals($signal)
 {
     $this->Logger->debug("HandleSignals received signal {$signal}");
     if ($signal == SIGUSR2) {
         $this->Logger->debug("Recived SIGUSR2 from one of childs");
         $this->ProcessManager->PIDs = array();
         $this->ProcessManager->ForkThreads();
         return;
     }
     $pid = @pcntl_wait($status, WNOHANG | WUNTRACED);
     if ($pid > 0) {
         $this->Logger->debug("Application received signal {$signal} from child with PID# {$pid} (Exit code: {$status})");
         foreach ((array) $this->ProcessManager->PIDs as $ipid => $ipid_info) {
             if ($ipid == $pid) {
                 unset($this->ProcessManager->PIDs[$ipid]);
                 if ($this->ProcessManager->PIDDir) {
                     $this->Logger->debug("Delete thread PID file {$ipid}");
                     @unlink($this->ProcessManager->PIDDir . "/" . $ipid);
                 }
                 $known_child = true;
                 break;
             }
         }
         if ($known_child) {
             $this->ProcessManager->ForkThreads();
         } else {
             $this->Logger->debug("Signal received from unknown child.");
         }
     }
 }
示例#3
0
       /**
        * Signals handler function
        *
        * @param integer $signal
        * @final 
        */
       final public function HandleSignals($signal)
       {
           //Log::Log("HandleSignals received signal {$signal}", E_NOTICE);            
           $pid = @pcntl_wait($status, WNOHANG | WUNTRACED);
           
           if ($pid > 0)
   		{
   		    //Log::Log("Application received signal {$signal} from child with PID# {$pid} (Exit code: {$status})", E_NOTICE);
 
   		    foreach((array)$this->ProcessManager->PIDs as $kk=>$vv)
   			{
   				if ($vv == $pid)
   				{
   					unset($this->ProcessManager->PIDs[$kk]);
   					$known_child = true;
   					break;
   				}
   			}
   			
   			if ($known_child)
   				$this->ProcessManager->ForkThreads();
   			else
   			{
   				//Log::Log("Signal received from unknown child.", E_NOTICE);
   			}
   		}
       }
示例#4
0
 public function __construct($bookId, $options = array())
 {
     $this->deleteSourceFile = false;
     parent::__construct($bookId, $options);
     $this->sourceFiles = array();
     if ($this->getOptionValue('deleteSourceFile') == 'true') {
         $this->deleteSourceFile = true;
     }
 }
示例#5
0
文件: Daemon.php 项目: grongor/phpd
 /**
  * @param int $type
  */
 private function signalHandler($type)
 {
     if (in_array($type, [SIGHUP, SIGTERM, SIGINT])) {
         $this->isRunning = false;
     } else {
         if ($type === SIGCHLD) {
             $childrenExited = $this->processManager->processChildExited();
             foreach ($childrenExited as $pid => $returnCode) {
                 if ($returnCode !== 0) {
                     $this->handleWorkerError();
                     $this->onWorkerFinished($pid, true);
                 } else {
                     $this->onWorkerFinished($pid, false);
                 }
                 if ($this->isRunning) {
                     $this->onWorkerAvailable();
                 }
             }
         } else {
             $this->logger->info(sprintf('Unknown signal %d', $type));
         }
     }
 }
 function compile_activity($pId, $activityId)
 {
     $act_info = $this->get_activity($pId, $activityId);
     $actname = $act_info['normalized_name'];
     $pm = new ProcessManager($this->db);
     $proc_info = $pm->get_process($pId);
     $compiled_file = GALAXIA_PROCESSES . '/' . $proc_info['normalized_name'] . '/compiled/' . $act_info['normalized_name'] . '.php';
     $template_file = GALAXIA_PROCESSES . '/' . $proc_info['normalized_name'] . '/code/templates/' . $actname . '.tpl';
     $user_file = GALAXIA_PROCESSES . '/' . $proc_info['normalized_name'] . '/code/activities/' . $actname . '.php';
     $pre_file = GALAXIA_LIBRARY . '/compiler/' . $act_info['type'] . '_pre.php';
     $pos_file = GALAXIA_LIBRARY . '/compiler/' . $act_info['type'] . '_pos.php';
     $fw = fopen($compiled_file, "wb");
     // First of all add an include to to the shared code
     $shared_file = GALAXIA_PROCESSES . '/' . $proc_info['normalized_name'] . '/code/shared.php';
     fwrite($fw, '<' . "?php include_once('{$shared_file}'); ?" . '>' . "\n");
     // Before pre shared
     $fp = fopen(GALAXIA_LIBRARY . '/compiler/_shared_pre.php', "rb");
     while (!feof($fp)) {
         $data = fread($fp, 4096);
         fwrite($fw, $data);
     }
     fclose($fp);
     // Now get pre and pos files for the activity
     $fp = fopen($pre_file, "rb");
     while (!feof($fp)) {
         $data = fread($fp, 4096);
         fwrite($fw, $data);
     }
     fclose($fp);
     // Get the user data for the activity
     $fp = fopen($user_file, "rb");
     while (!feof($fp)) {
         $data = fread($fp, 4096);
         fwrite($fw, $data);
     }
     fclose($fp);
     // Get pos and write
     $fp = fopen($pos_file, "rb");
     while (!feof($fp)) {
         $data = fread($fp, 4096);
         fwrite($fw, $data);
     }
     fclose($fp);
     // Shared pos
     $fp = fopen(GALAXIA_LIBRARY . '/compiler/_shared_pos.php', "rb");
     while (!feof($fp)) {
         $data = fread($fp, 4096);
         fwrite($fw, $data);
     }
     fclose($fp);
     fclose($fw);
     //Copy the templates
     if ($act_info['isInteractive'] == 'y' && !file_exists($template_file)) {
         $fw = fopen($template_file, 'w');
         if (defined('GALAXIA_TEMPLATE_HEADER') && GALAXIA_TEMPLATE_HEADER) {
             fwrite($fw, GALAXIA_TEMPLATE_HEADER . "\n");
         }
         fclose($fw);
     }
     if ($act_info['isInteractive'] != 'y' && file_exists($template_file)) {
         @unlink($template_file);
         if (GALAXIA_TEMPLATES && file_exists(GALAXIA_TEMPLATES . '/' . $proc_info['normalized_name'] . "/{$actname}.tpl")) {
             @unlink(GALAXIA_TEMPLATES . '/' . $proc_info['normalized_name'] . "/{$actname}.tpl");
         }
     }
     if (GALAXIA_TEMPLATES && file_exists($template_file)) {
         @copy($template_file, GALAXIA_TEMPLATES . '/' . $proc_info['normalized_name'] . "/{$actname}.tpl");
     }
 }
示例#7
0
 /**
  * Runs the command
  *
  * @param string|resource $stdin The string contents for STDIN or a stream resource to be consumed
  * @param bool $throw_exceptions If true (default), an exception will be thrown if the command fails
  * @return Command - Fluent interface
  * @throws CommandException The command failed
  */
 public function run($stdin = null, $throw_exceptions = true)
 {
     // Clear previous run
     $this->exitcode = null;
     $this->stdout = null;
     $this->stderr = null;
     $this->timestart = microtime(true);
     // Prepare the buffers structure
     $buffers = [self::STDIN => $stdin, self::STDOUT => &$this->stdout, self::STDERR => &$this->stderr];
     $process = new ProcessManager($this->getFullCommand(), $buffers);
     $this->exitcode = $process->exec($this->callback, $this->callbacklines, $this->readbuffer, $this->cwd, $this->env, $this->conf);
     $this->timeend = microtime(true);
     if ($throw_exceptions && $this->exitcode !== 0) {
         throw new CommandException($this, "Command failed '{$this}':\n" . trim($this->getStdErr()));
     }
     return $this;
 }
示例#8
0
 /**
  * killAll
  *
  * Kill All running processes.
  *
  * @access public
  * @return boolean
  */
 function killAll()
 {
     $_this =& ProcessManager::getInstance();
     $runningProcesses = $_this->getKeys();
     foreach ($runningProcesses as $name) {
         $_this->_processes[$name]->kill();
         unset($_this->_processes[$name]);
     }
     return true;
 }
示例#9
0
<?php

// Load configuration of the Galaxia Workflow Engine
include_once dirname(__FILE__) . '/config.php';
include_once GALAXIA_LIBRARY . '/src/ProcessManager/ProcessManager.php';
include_once GALAXIA_LIBRARY . '/src/ProcessManager/InstanceManager.php';
include_once GALAXIA_LIBRARY . '/src/ProcessManager/RoleManager.php';
include_once GALAXIA_LIBRARY . '/src/ProcessManager/ActivityManager.php';
include_once GALAXIA_LIBRARY . '/src/ProcessManager/GraphViz.php';
/// $roleManager is the object that will be used to manipulate roles.
$roleManager = new RoleManager();
/// $activityManager is the object that will be used to manipulate activities.
$activityManager = new ActivityManager();
/// $processManager is the object that will be used to manipulate processes.
$processManager = new ProcessManager();
/// $instanceManager is the object that will be used to manipulate instances.
$instanceManager = new InstanceManager();
if (defined('GALAXIA_LOGFILE') && GALAXIA_LOGFILE) {
    include_once GALAXIA_LIBRARY . '/src/Observers/Logger.php';
    $logger = new Logger(GALAXIA_LOGFILE);
    $processManager->attach_all($logger);
    $activityManager->attach_all($logger);
    $roleManager->attach_all($logger);
}
示例#10
0
 public function __construct($bookId, $options = array())
 {
     parent::__construct($bookId);
     $this->options = $options;
 }
示例#11
0
 function Launch($max_chinds = 5)
 {
     $proccess = new ReflectionClass("{$this->ProcessName}Process");
     $sig_handler = new ReflectionClass("SignalHandler");
     $PR = new ProcessManager($sig_handler->newInstance());
     $PR->SetMaxChilds($max_chinds);
     $PR->Run($proccess->newInstance());
 }
示例#12
0
 function Launch($max_chinds = 5, $child_exec_timeout = 0)
 {
     $proccess = new ReflectionClass("{$this->ProcessName}Process");
     $sig_handler = new ReflectionClass("SignalHandler");
     $PR = new ProcessManager($sig_handler->newInstance());
     $PR->SetChildExecLimit($child_exec_timeout);
     $PR->SetMaxChilds($max_chinds);
     if ($this->PIDDir) {
         $PR->SetPIDDir($this->PIDDir);
     }
     $PR->Run($proccess->newInstance());
 }
示例#13
0
 function Launch($max_chinds = 5, $child_exec_timeout = 0)
 {
     $proccess = new \ReflectionClass("{$this->ProcessName}Process");
     $sh = new \ReflectionClass('Scalr\\System\\Pcntl\\SignalHandler');
     $pm = new ProcessManager($sh->newInstance());
     $pm->SetChildExecLimit($child_exec_timeout);
     $pm->SetMaxChilds($max_chinds);
     if ($this->PIDDir) {
         $pm->SetPIDDir($this->PIDDir);
     }
     $pm->Run($proccess->newInstance());
 }
示例#14
0
<?php

require_once "ProcessManager.php";
$manager = new ProcessManager();
//$manager->executable  = "php";
$manager->addScript("doit.php 1", 5);
$manager->addScript("doit.php 2", 10);
$manager->addScript("doit.php 3", 35);
$manager->addScript("doit.php 4", 5);
$manager->addScript("doit.php 5", 10);
$manager->addScript("doit.php 6", 35);
$manager->exec();
示例#15
0
<?php
/**
 * Display logs
 */

$Module = $Params['Module'];

$tpl = eZTemplate::factory();
$tpl->setVariable( 'module', $Module );

$manager = ProcessManager::instance();

$tpl->setVariable( 'output', file_get_contents($manager->getOutputFile()) );
$tpl->setVariable( 'errors', file_get_contents($manager->getErrorFile()) );

$Result = array();
$Result['content'] = $tpl->fetch( 'design:cronjobs/logs.tpl' );
$Result['left_menu'] = "design:cronjobs/backoffice_left_menu.tpl";
//$Result['pagelayout'] = null;
$Result['path'] = array( array( 'url' => '/cronjobs/logs/',
                                'text' => ezpI18n::tr( 'ezcronjobs', 'Cronjobs' ) ),
                         array( 'url' => false,
                                'text' => 'logs' ) );



?>