public function run()
 {
     ob_start();
     error_reporting(E_ALL ^ E_NOTICE);
     if (defined('COMACO_LOG')) {
         $log = 'contao-management-console';
         if (defined('COMACO_LOG_NAME')) {
             $log = COMACO_LOG_NAME;
         }
         $logger = new Logger($log);
         $logger->pushHandler(new StreamHandler(COMACO_LOG, COMACO_LOG_LEVEL));
     } else {
         $logger = null;
     }
     if (isset($_GET['ping'])) {
         header('Content-Type: text/plain; charset=utf-8');
         echo 'pong';
         exit;
     }
     $settings = new Settings();
     if (defined('COMACO_CONTAO_PATH')) {
         $settings->setPath(COMACO_CONTAO_PATH);
     }
     if (defined('COMACO_RSA_LOCAL_PRIVATE_KEY')) {
         $settings->setRsaLocalPrivateKey(COMACO_RSA_LOCAL_PRIVATE_KEY);
     }
     if (defined('COMACO_RSA_REMOTE_PUBLIC_KEY')) {
         $settings->setRsaRemotePublicKey(COMACO_RSA_REMOTE_PUBLIC_KEY);
     }
     $factory = new EndpointFactory();
     $endpoint = $factory->createEndpoint($settings);
     $transport = new HttpServer('application/json');
     if ($logger) {
         $transport->setLogger($logger);
     }
     $encoder = new JsonRpc20Encoder();
     if ($logger) {
         $encoder->setLogger($logger);
     }
     if ($settings->isEncryptionEnabled()) {
         $encoder = new RsaEncoder($encoder, $settings->getRsaRemotePublicKey(), $settings->getRsaLocalPrivateKey());
     }
     $server = new Server($transport, $encoder, $endpoint);
     try {
         $server->handle();
     } catch (Exception $e) {
         if ($logger && $logger->isHandling(Logger::ERROR)) {
             $logger->addError($e->getMessage());
         }
         ob_start();
         while (ob_end_clean()) {
         }
         header('HTTP/1.0 500 Internal Server Error');
         header("Status: 500 Internal Server Error");
         header('Content-Type: text/plain; charset=utf-8');
         echo '500 Internal Server Error';
     }
     exit;
 }
 protected function createSettings(InputInterface $input)
 {
     $settings = new Settings();
     $settings->setPath($input->getArgument('target'));
     $privateKeyFile = $input->getOption('private-key');
     if (!empty($privateKeyFile)) {
         $settings->setRsaLocalPrivateKey(file_get_contents($privateKeyFile));
     }
     $publicKeyFile = $input->getOption('public-key');
     if (!empty($publicKeyFile)) {
         $settings->setRsaRemotePublicKey(file_get_contents($publicKeyFile));
     }
     return $settings;
 }