Run

@access public
4525
public function run() {
		// initializing
		$this->max_processes = Config::$max_processes;

		// unlocking all transactions in case the process did not stop properly
		Transaction::unlock_all();

		// initializing the processes array to free slots
		for ($i = 0; $i <= $this->max_processes; $i++) {
			$this->processes[$i] = -1;
		}

		// run forever
		while (true) {

			// counters for parallels and non-parallel transactions
			$not_parallel_free = 0;
			$parallels_free = 0;

			// cleaning processes array before to begin
			$this->clean_slots($not_parallel_free, $parallels_free);
			while ($not_parallel_free + $parallels_free == 0) {				// if all slots are used then sleep
				usleep(100000);												// for 1/10 second and see if one or
				$this->clean_slots($not_parallel_free, $parallels_free);	// more slot got freed
			}

			try {
				$transactions = Transaction::get_runnable();
			} catch (\ErrorException $e) {
				// FIXME: this doesn't work as expected, impossible to catch database server off and retry in a second
				printf("%s\n", $e->getMessage());
				sleep(1);
				continue;
			}
			if (count($transactions) == 0) {	// if there is no transaction to
				sleep(1);						// process then sleep for a second
				continue;						// and start over
			}

			// testing every slot and if empty looking for a transaction to start
			for ($i = 0; $i < $this->max_processes; $i++) {
				if ($this->is_slot_free($i)) {
					if ($i == 0) {
						$transaction = $this->get_first_transaction($transactions, false);
					} else {
						$transaction = $this->get_first_transaction($transactions, true);
					}
					if ($transaction != null) {
//printf("Slot %d -> %s (%d)\n", $i, $transaction->classname, $transaction->id);
						$sleep = 0; // as the queue of transactions is not empty, we won't sleep
						\Skeleton\Database\Database::reset();
						$pid = pcntl_fork();
						if ($pid == -1) {
							die('Could not fork');
						} else if ($pid) {
							// PARENT
							$this->lock_slot($i, $pid);
						} else {
							// CHILD
							cli_set_process_title(strtolower($transaction->classname) . ' (' . $transaction->id . ')');
							$runner = new Runner();
							$runner->run_transaction($transaction);
							$transaction->unlock();
							exit;
						}
					}
				}
			}
		}
	}
1091791
public function run()
    {
        $table = \Input::get('table');
        $field = \Input::get('field');
        $name  = \Input::get('name');
        $rowId = \Input::get('id');

        $dataContainer = $this->initializeDataContainer($table, $field);
        $this->loadRow($table, $rowId, $dataContainer);

        $template = $this->prepareTemplate();

        $template->table = $table;
        $template->field = $field;
        $template->name  = $name;
        $template->icon  = $dataContainer->activeRecord->$field;
        $template->icons = $this->generateIcons($field);

        $template->output();
    }
160259
public function run() {
		$this->load_hooks();

		// Need to ensure these classes are activated here for hooks to fire.
		if ( $this->is_current_page( [ 'options.php', 'options-general.php', 'settings.php' ] ) ) {
			Singleton::get_instance( 'Install', $this )->run();
			Singleton::get_instance( 'Remote_Management', $this )->load_hooks();
		}
	}
1111247
public function run()
	{
		$clip=ob_get_clean();
		if($this->renderClip)
			echo $clip;
		$this->getController()->getClips()->add($this->getId(),$clip);
	}
1186846
public function run()
    {
        $this->setUserAndGroup();

        $out = $this->out;
        $err = $this->err;
        $process = new \Symfony\Component\Process\Process($this->cmd, null, null, null, null);
        $process->run(function ($type, $buffer) use ($out, $err) {
            if ($type == \Symfony\Component\Process\Process::ERR) {
                $err->error($buffer);
            } else {
                $out->info($buffer);
            }
        });
    }
958662
public function run()
    {
        try
        {
            $this['triggers']->callTrigger('before-match-request', $this);

            $this['request']->attributes->add(
                $this['router']->matchRequest($this['request'])
            );

            $this['triggers']->callTrigger('before-controller-resolver', $this);

            $this['response'] = $this->controllerResolver();
        }
        catch (ResourceNotFoundException $e)
        {
            $this['response'] = (new Controller($this))->serve404();
        }
        catch (\Exception $e)
        {
            $this['response'] = new Response();
            $this['response']->headers->set('Content-Type', 'text/plain');
            $this['response']->setStatusCode(Response::HTTP_INTERNAL_SERVER_ERROR);
            $this['response']->setContent($e->getMessage());
        }

        if ($this['x-frame-options']) {
            $this['response']->headers->set('x-frame-options', $this['x-frame-options']);
        }

        $this['response']->prepare($this['request']);

        $this['triggers']->callTrigger('before-send-response', $this);

        $this['response']->send();
    }
789757
public function run()
    {
        CommonFunctions::checkForExtensions(array('xsl'));
        $xmlfile = $this->getXMLString();
        $xslfile = "phpsysinfo.xslt";
        $domxml = new DOMDocument();
        $domxml->loadXML($xmlfile);
        $domxsl = new DOMDocument();
        $domxsl->load($xslfile);
        $xsltproc = new XSLTProcessor;
        $xsltproc->importStyleSheet($domxsl);
        echo $xsltproc->transformToXML($domxml);
    }
530460
public function run()
    {
        // Setting up the styles
        echo '<style type="text/css">';
        echo '#bodydiv { font: 10px sans-serif;}';
        foreach ($this->styles as $class => $style) {
            echo '.', $class, ' { ';
            if ($style['font'] === 'dejavusans') {
                $style['font'] = $this->default_font;
            }
            echo 'font-family: ', $style['font'], '; ';
            echo 'font-size: ', $style['size'], 'pt; ';
            // Case-insensitive
            if (stripos($style['style'], 'B') !== false) {
                echo 'font-weight: bold; ';
            }
            if (stripos($style['style'], 'I') !== false) {
                echo 'font-style: italic; ';
            }
            if (stripos($style['style'], 'U') !== false) {
                echo 'text-decoration: underline; ';
            }
            if (stripos($style['style'], 'D') !== false) {
                echo 'text-decoration: line-through; ';
            }
            echo '}', PHP_EOL;
        }
        unset($class, $style);
        //-- header divider
        echo '</style>', PHP_EOL;
        echo '<div id="headermargin" style="position: relative; top: auto; height: ', $this->header_margin, 'pt; width: ', $this->noMarginWidth, 'pt;"></div>';
        echo '<div id="headerdiv" style="position: relative; top: auto; width: ', $this->noMarginWidth, 'pt;">';
        foreach ($this->headerElements as $element) {
            if ($element instanceof ReportBaseElement) {
                $element->render($this);
            } elseif ($element === 'footnotetexts') {
                $this->footnotes();
            } elseif ($element === 'addpage') {
                $this->addPage();
            }
        }
        //-- body
        echo '</div>';
        echo '<script>document.getElementById("headerdiv").style.height="', $this->top_margin - $this->header_margin - 6, 'pt";</script>';
        echo '<div id="bodydiv" style="position: relative; top: auto; width: ', $this->noMarginWidth, 'pt; height: 100%;">';
        $this->Y    = 0;
        $this->maxY = 0;
        $this->runPageHeader();
        foreach ($this->bodyElements as $element) {
            if ($element instanceof ReportBaseElement) {
                $element->render($this);
            } elseif ($element === 'footnotetexts') {
                $this->footnotes();
            } elseif ($element === 'addpage') {
                $this->addPage();
            }
        }
        //-- footer
        echo '</div>';
        echo '<script>document.getElementById("bodydiv").style.height="', $this->maxY, 'pt";</script>';
        echo '<div id="bottommargin" style="position: relative; top: auto; height: ', $this->bottom_margin - $this->footer_margin, 'pt;width:', $this->noMarginWidth, 'pt;"></div>';
        echo '<div id="footerdiv" style="position: relative; top: auto; width: ', $this->noMarginWidth, 'pt;height:auto;">';
        $this->Y    = 0;
        $this->X    = 0;
        $this->maxY = 0;
        foreach ($this->footerElements as $element) {
            if ($element instanceof ReportBaseElement) {
                $element->render($this);
            } elseif ($element === 'footnotetexts') {
                $this->footnotes();
            } elseif ($element === 'addpage') {
                $this->addPage();
            }
        }
        echo '</div>';
        echo '<script>document.getElementById("footerdiv").style.height="', $this->maxY, 'pt";</script>';
        echo '<div id="footermargin" style="position: relative; top: auto; height: ', $this->footer_margin, 'pt;width:', $this->noMarginWidth, 'pt;"></div>';
    }
155160
public function run()
    {
        $block = trim(ob_get_clean());
        $this->registerCssBlock($block);
        $this->registerJsBlock($block);
    }
191037
public function run()
    {
        $data       = $this->parseRequestUri();
        $controller = $data['controller'];
        $method     = $data['method'];
        $params     = $data['params'];

        $subModule  = $this->subModule;
        if ("" != $subModule) {
            $subModule = "\\" . $subModule;
        }

        $class      = sprintf("%s\\Controller%s\\%sController", $this->appNameSpace, $subModule, $controller);
        if (!(class_exists($class) && method_exists($class, $method))) {
            $this->fileNotFound();
        } else {
            $class  = new $class;
            $pipe = new Pipeline();
            $pipe->through($class->getMiddleWare())->then(function () use ($class, $method, $params) {
                call_user_func_array(array($class, $method), $params);
            });

            //call_user_func_array(array($class, $method), $params);
        }
    }
1351364
public function run() {
			$this->execute();

			if ($handler = $this->getFormHandler(@$_REQUEST['_form_name']))
				call_user_func($handler, $_REQUEST);
		}
427240
public function run()
    {
        Scripts::initializeClassLoader($this);
        Scripts::initializeSignalSlot($this);
        Scripts::initializePackageManagement($this);

        $this->activeRequestHandler = $this->resolveRequestHandler();
        $this->activeRequestHandler->handleRequest();
    }
1285564
public function run()
    {
        $table = $this->table(CMS_TABLE_GROUPS);
        $table->insert($this->records)->save();
    }
780173
private function _run(): void
  {
    // The DB and the controller exist
    if ( $this->check() && isset($this->data['type'])){
      if ( !defined('BBN_EXTERNAL_USER_ID') && defined('BBN_EXTERNAL_USER_EMAIL') ){
        define('BBN_EXTERNAL_USER_ID', $this->db->select_one('bbn_users', 'id', ['email' => BBN_EXTERNAL_USER_EMAIL]));
      }
      if ( defined('BBN_EXTERNAL_USER_ID') && class_exists('\\bbn\\appui\\history') ){
        \bbn\appui\history::set_user(BBN_EXTERNAL_USER_ID);
      }
      $type = $this->data['type'];
      // Removing file cache
      clearstatcache();
      // only 2 types: poll or cron
      if ( $type !== 'poll' ){
        $type = 'cron';
      }
      $pid = $this->get_pid_path($this->data);

      // Checking for the presence of the manual files
      if (
        !$this->is_active() ||
        (($type === 'cron') && !$this->is_cron_active()) ||
        (($type === 'poll') && !$this->is_poll_active())
      ){
        // Exiting the script if one is missing
        if ( is_file($pid) ){
          @unlink($pid);
        }
        exit("GETTING OUT of $type BECAUSE one of the manual files is missing");
      }
      // Loooking for a running PID
      if ( is_file($pid) && ($file_content = @file_get_contents($pid)) ){
        $pid_content = explode('|', $file_content);
        if ( $pid_content[1] && file_exists('/proc/'.$pid_content[0]) ){
          // If it's currently running we exit
          exit("There is already a process running with PID ".file_get_contents($pid)." in $pid");
        }
        else{
          // Otherwise we delete the PID file
          echo "DELETING FILEPID AS THE PROCESS IS DEAD ".implode(PHP_EOL, $pid_content).PHP_EOL;
          @unlink($pid);
        }
      }
      // We create the PID file corresponding to the current process
      file_put_contents($pid, getmypid().'|'.time());
      $cron =& $this;
      // Shutdown function, will be always executed, except if the server is stopped
      register_shutdown_function(function() use($cron){
        $data = $cron->get_data();
        $pid = $this->get_pid_path($data);
        $file_content = @file_get_contents($pid);
        // Write the error log if an error is present
        if ( $error = error_get_last() ){
          @file_put_contents($cron->get_error_log_path($data), \bbn\x::get_dump($error));
          if ( defined('BBN_DATA_PATH') && is_dir(BBN_DATA_PATH.'logs') ){
            bbn\x::log([$data, $error], 'cron');
          }
        }
        $ok = true;
        // We check if there is a problem with the PID file (it's only debug it shouldn't be necessary)
        if ( $file_content ){
          echo $file_content.PHP_EOL;
          $pid_content = explode('|', $file_content);
          if ( $pid_content[1] && ($pid_content[0] != getmypid()) ){
            echo 'Different processes: '.$pid_content[0].'/'.getmypid().PHP_EOL;
            $ok = false;
          }
        }
        if ( $ok && isset($data['type']) ){
          // We output the ending time (as all output will be logged in the output file
          echo 'SHUTDOWN '.date('H:i:s');
          // Removing PID file
          if ( is_file($pid) ){
            @unlink($pid);
          }
          // And relaunching the continuous tasks if we are in the poller...
          if ( ($data['type'] === 'poll') && $cron->is_poll_active() ){
            $cron->launch_poll();
          }
          else if ( !array_key_exists('id', $data) && ($data['type'] === 'cron') && $cron->is_cron_active() ){
            $cron->launch_task_system();
          }
        }
      });
      // And here we really do what we have to do
      // Poll case
      if ( $type === 'poll' ){
        $this->poll();
      }
      else if ( $type === 'cron' ){
        if ( array_key_exists('id', $this->data) ){
          echo 'Launching task...';
          $this->run_task($this->data);
        }
        else{
          $this->run_task_system();
        }
      }
    }
  }
38805
public function run()
    {
        $request = Request::createFromGlobals();
        $response = $this->handle($request);
        $response->send();

        $this->invokeFinish([], [$this, $request, $response]);
    }
275121
public function run()
	{
		$this->renderContent();
		$content=ob_get_clean();
		if($this->hideOnEmpty && trim($content)==='')
			return;
		echo $this->_openTag;
		echo $content;
		echo "</div>\n";
		echo CHtml::closeTag($this->tagName);
	}
805683
public function run()
    {
        Model::unguard();

        // Users
        $users = [
            [
                'first_name' => 'Su',
                'last_name' => 'Acl',
                'email' => 'su@acl.com',
                'password' => bcrypt('123'),
                'superuser' => TRUE,
                'remember_token' => str_random(10),
                'created_at' => date('Y-m-d H:i:s'),
                'updated_at' => date('Y-m-d H:i:s'),
            ],
        ];

        DB::table('users')->insert($users);

        // Roles
        $roles = [
            [
                'name' => 'Admin',
                'description' => 'Admin',
            ],
        ];

        DB::table('roles')->insert($roles);
    }