コード例 #1
0
 function resolve(Request $request, Response $response)
 {
     if ($response->status() != 200) {
         return;
         // only normal response will be processed
     }
     foreach ((array) $request->meta('output') as $outputFilter) {
         // format: func([param1[,param2[,param3 ...]]])
         if (preg_match('/(\\w+)\\(([\\w\\s,]*)\\)/', $outputFilter, $matches)) {
             $func = @$this->funcMap[$matches[1]];
             if (is_callable($func)) {
                 if (@$matches[2]) {
                     $func = call_user_func_array($func, explode(',', $matches[2]));
                 }
                 if (is_callable($func)) {
                     try {
                         $response->send(call_user_func_array($func, array($response->body())));
                     } catch (\Exception $e) {
                         Log::error(sprintf('[InvokerPostProcessor] Error calling %s(): %s @ %s:%d', $matches[1], $e->getMessage(), basename($e->getFile()), $e->getLine()), $e->getTrace());
                         $response->send(array('error' => $e->getMessage(), 'code' => $e->getCode()), 500);
                     }
                 }
             }
         }
     }
 }
コード例 #2
0
ファイル: Process.php プロジェクト: Victopia/prefw
            $schedule = ['command' => $schedule['command'], 'start_time' => $nextTime, 'schedule_name' => $schedule['name'], '$type' => 'cron', '$spawn' => false];
            Log::debug('Scheduling new process', $schedule);
            Process::enqueue($schedule['command'], $schedule);
        }
    };
    // Configuration based crontab
    array_map($scheduler, (array) conf::get('crontab::schedules'));
}
// Avoid forking connection crash, renew the connection.
Database::disconnect();
// Forks then exits the parent.
// Use nohup if internal forking is not supported.
if (!function_exists('pcntl_fork')) {
    $ret = shell_exec('nohup ' . Process::EXEC_PATH . ' --nohup >/dev/null 2>&1 & echo $!');
    if (!$ret) {
        Log::error('Process cannot be spawn, please review your configuration.');
    }
    die;
} elseif (@$opts['n']) {
    $pid = 0;
    // fork mimic
} else {
    $pid = pcntl_fork();
}
// parent: $forked == false
// child:  $forked == true
$forked = $pid == 0;
// unset($pid);
// parent will die here
if (!$forked) {
    exit(1);
コード例 #3
0
ファイル: Eny.php プロジェクト: sinfey69/enyphp
 /**
  * 自定义错误处理机制
  * @param int 错误代码
  * @param string 错误信息
  * @param string 错误文件
  * @param int 错误行号
  * @return void
  */
 public static function appError($errno, $errstr, $errfile, $errline)
 {
     // 错误记录
     Log::error($error[$errno], $errstr, $errfile, $errline);
     // 服务器错误
     Response::_500();
 }