Exemplo n.º 1
0
 public function testLoggingMethods()
 {
     Logger::emergency("Test logger!");
     Logger::alert("Test logger!");
     Logger::critical("Test logger!");
     Logger::error("Test logger!");
     Logger::warning("Test logger!");
     Logger::notice("Test logger!");
     Logger::info("Test logger!");
     Logger::debug("Test logger!");
     $this->assertStringEqualsFile(vfsStream::url("logs/file.log"), $this->log);
 }
Exemplo n.º 2
0
 /**
  *
  * @return ajumamoro\Store
  */
 public static function getInstance()
 {
     $delay = 30;
     while (self::$instance === null) {
         try {
             self::$instance = self::factory();
             self::$instance->init();
         } catch (exceptions\BrokerConnectionException $e) {
             Logger::alert("{$e->getMessage()}. Retrying in {$delay} seconds.");
             sleep($delay);
             $delay *= 2;
         }
     }
     Logger::info("Succesfully connected to broker");
     return self::$instance;
 }
Exemplo n.º 3
0
 private function startDaemon($options)
 {
     $pid = pcntl_fork();
     if ($pid == -1) {
         Logger::error("Sorry! could not start daemon.\n");
     } else {
         if ($pid) {
             Logger::info("Daemon started with pid {$pid}.\n");
             $pidFile = Config::get('ajumamoro:pid_file', './ajumamoro.pid');
             file_put_contents($pidFile, $pid);
         } else {
             Runner::mainLoop($options);
         }
     }
     return $pid;
 }
Exemplo n.º 4
0
 public static function mainLoop()
 {
     $bootstrap = Config::get('ajumamoro:bootstrap');
     if ($bootstrap) {
         require Config::get("ajumamoro:bootstrap");
     }
     Logger::info("Starting Ajumamoro");
     set_error_handler(function ($no, $message, $file, $line) {
         Logger::error("Job #" . self::$jobId . " Warning {$message} on line {$line} of {$file}");
     }, E_WARNING);
     // Get Store;
     $delay = Config::get('delay', 200);
     do {
         $job = self::getNextJob();
         if ($job !== false) {
             self::executeJob($job);
         } else {
             usleep($delay);
         }
     } while (true);
 }