public function registerCodeRunner()
 {
     $target = Config::$SERVER_URL . Config::$CORE['register_runner_link'];
     $http_request = new HttpRequest();
     $http_request->setTargetUrl($target)->setHeader(self::$APP_ID_KEY, Config::$APPLICATION_ID)->setHeader(self::$SECRET_KEY, Config::$SECRET_KEY)->setHeader(self::$VERSION, Config::$APP_VERSION)->setHeader('Content-type', 'application/json')->request(json_encode(array('lang' => Config::$CORE['lang'])));
     if ($http_request->getResponseCode() != 200) {
         $msg = "CodeRunner registration fail, HTTP response code: " . $http_request->getResponseCode() . " response status: " . $http_request->getResponseStatus();
         Log::writeError($msg, $target = 'file');
         throw new CodeRunnerException($msg);
     } else {
         Config::$STATUS = "registered";
         Config::$DEBUG_ID = json_decode($http_request->getResponce(), true)['debugId'];
         if (!isset(Config::$DEBUG_ID)) {
             $msg = "CodeRunner can't get  debugid.";
             Log::writeError($msg, $target = 'all');
             exit;
         }
     }
 }
 public function __construct($msg)
 {
     parent::__construct();
     $msg_as_array = json_decode($msg, true);
     $this->id = $msg_as_array['id'];
     $this->application_id = $msg_as_array['applicationId'];
     $this->app_version_id = $msg_as_array['appVersionId'];
     $this->event_id = $msg_as_array['eventId'];
     $this->arguments = $msg_as_array['arguments'];
     $this->target = $msg_as_array['target'];
     $this->timeout = $msg_as_array['timeout'];
     $this->async = $msg_as_array['async'];
     $this->decoded_arguments = null;
     if (GlobalState::$TYPE === 'CLOUD') {
         $this->relative_path = $msg_as_array['relativePath'];
         Config::$RELATIVE_PATH = $msg_as_array['relativePath'];
         Config::$TASK_APPLICATION_ID = $msg_as_array['applicationId'];
         ClassManager::analyze();
     }
 }
 public function registerCodeRunner()
 {
     $target = Config::$SERVER_URL . Config::$CORE['register_runner_link'];
     $http_request = new HttpRequest();
     $http_request->setTargetUrl($target)->setHeader(self::$APP_ID_KEY, Config::$APPLICATION_ID)->setHeader(self::$SECRET_KEY, Config::$SECRET_KEY)->setHeader(self::$VERSION, Config::$APP_VERSION)->setHeader('Content-type', 'application/json')->request(json_encode(array('lang' => Config::$CORE['lang'])));
     if ($http_request->getResponseCode() != 200) {
         $msg = "CodeRunner registration fail, HTTP response code: " . $http_request->getResponseCode() . " response status: " . $http_request->getResponseStatus();
         Log::writeError($msg, $target = 'file');
         throw new CodeRunnerException($msg);
     } else {
         Config::$STATUS = "registered";
         Config::$DEBUG_ID = json_decode($http_request->getResponce(), true)['debugId'];
         // TODO: delete after test
         //Config::$DEBUG_ID = "51591778-2B61-B82F-FF33-B7B5F460FD00:8C902CEE-643E-C017-FF7D-C05ACC97C600:CodeRunnerDebug-TEST-DIMA";
         if (!isset(Config::$DEBUG_ID)) {
             $msg = "CodeRunner can't get  debugid.";
             Log::writeError($msg, $target = 'all');
             exit;
         }
     }
 }
<?php

//enable the display of errors
//error_reporting(E_ALL);
//ini_set('display_errors', true);
use backendless\core\lib\Autoload;
use backendless\core\RedisManager;
use backendless\core\Config;
// define short constants
define('DS', DIRECTORY_SEPARATOR);
define('BP', dirname(dirname(__FILE__)));
//include file with backendkess autoloader
include "lib" . DS . "Autoload.php";
//include file with predis autoloader
include "lib" . DS . "predis" . DS . "autoload.php";
// initialize app autoloading
Autoload::register();
Autoload::addNamespace('backendless\\core', BP . DS . 'core');
Config::loadConfig();
$predis = RedisManager::getInstance()->getRedis();
$debug_id = $argv[1];
for (;;) {
    $predis->expire($debug_id, 60);
    sleep(45);
}
 public static function phpEnviromentInit()
 {
     if (GlobalState::$TYPE === 'LOCAL') {
         //for LOCAL use user time zone or UTC if not set
         $timezone = @date_default_timezone_get();
         // if not set default timezone set as UTC
         if ($timezone == 'UTC') {
             date_default_timezone_set('UTC');
         }
     } else {
         date_default_timezone_set('UTC');
         // for CLOUDE use UTC
     }
     // check if available openssl for use https
     if (!extension_loaded("openssl")) {
         Log::writeWarn('PHP module "openssl" not installed or not switch on in php.ini file', $target = 'file');
         Config::setServerUrl(preg_replace('/^http:\\/\\/|https:\\/\\/(.*)$/', 'http://${1}', Config::$SERVER_URL));
         Log::writeWarn('All https requests to ' . Config::$SERVER_URL . 'changed on http requests', $target = 'file');
     }
 }
 private function register()
 {
     Log::writeInfo("Registering runner on: " . Config::$SERVER_URL . " with secretKey: " . Config::$SECRET_KEY);
     try {
         CodeRunnerUtil::getInstance()->registerCodeRunner();
         GlobalState::$STATE = 'REGISTERED';
         Log::writeInfo("Runner successfully registered.");
         Config::saveKeys();
     } catch (Exception $e) {
         Log::writeError("Runner registration failed.", $target = 'console');
         Log::writeError($e->getMessage(), $target = 'file');
         self::Stop();
         exit;
     }
 }
 protected function RequestServiceInvocation($msg)
 {
     /// invoke hosted servise action
     $rsi = new RequestServiceInvocation($msg);
     Log::writeInfo("Received RSI:" . $rsi, $target = 'file');
     if (GlobalState::$TYPE == 'CLOUD' && time() * 1000 - $rsi->getTimestamp() > $this->timeout) {
         Log::writeError("RSI ignored by timeout" . $rsi, $target = 'file');
         return;
     }
     if (GlobalState::$TYPE === 'CLOUD') {
         Config::$RELATIVE_PATH = $msg['relativePath'];
         Config::$TASK_APPLICATION_ID = $msg['applicationId'];
         //ClassManager::analyze( PathBuilder::getClasses() );
         ClassManager::analyze(PathBuilder::getHostedService($rsi->getAppVersionId(), $rsi->getRelativePath()));
     }
     $executor = $this->executor_holder->getCodeExecutor($rsi->getApplicationId(), $rsi->getAppVersionId());
     $executor->invokeService($rsi);
 }