public static function run()
    {
        foreach (Orm\CmsCronQuery::active()->find() as $cron) {
            if (!self::_getToExecute($cron)) {
                continue;
            }
            $output = '';
            try {
                $start = microtime(true);
                $output = \Mmi\Mvc\ActionHelper::getInstance()->action(new \Mmi\Http\Request(['module' => $cron->module, 'controller' => $cron->controller, 'action' => $cron->action]));
                $elapsed = round(microtime(true) - $start, 2);
            } catch (\Exception $e) {
                //error logging
                \Mmi\App\FrontController::getInstance()->getLogger()->error('CRON failed: @' . gethostname() . $cron->name . ' ' . $e->getMessage());
                return;
            }
            //zmień datę ostatniego wywołania
            $cron->dateLastExecute = date('Y-m-d H:i:s');
            //ponowne łączenie
            \App\Registry::$db->connect();
            //zapis do bazy bez modyfikowania daty ostatniej modyfikacji
            $cron->saveWithoutLastDateModify();
            //logowanie uruchomienia
            \Mmi\App\FrontController::getInstance()->getLogger()->info('CRON done: @' . gethostname() . ' ' . $cron->name . ' ' . $output .  ' in ' . $elapsed . 's');
        }
    }
public static function run()
    {
        foreach (Orm\CmsCronQuery::active()->find() as $cron) {
            if (!self::_getToExecute($cron)) {
                continue;
            }
            $output = '';
            try {
                $start = microtime(true);
                $output = \Mmi\Mvc\ActionHelper::getInstance()->action(new \Mmi\Http\Request(['module' => $cron->module, 'controller' => $cron->controller, 'action' => $cron->action]));
                $elapsed = round(microtime(true) - $start, 2);
            } catch (\Exception $e) {
                //error logging
                \Mmi\App\FrontController::getInstance()->getLogger()->error('CRON failed: @' . gethostname() . $cron->name . ' ' . $e->getMessage());
                return;
            }
            //zmień datę ostatniego wywołania
            $cron->dateLastExecute = date('Y-m-d H:i:s');
            //ponowne łączenie
            \App\Registry::$db->connect();
            //zapis do bazy bez modyfikowania daty ostatniej modyfikacji
            $cron->saveWithoutLastDateModify();
            //logowanie uruchomienia
            \Mmi\App\FrontController::getInstance()->getLogger()->info('CRON done: @' . gethostname() . ' ' . $cron->name . ' ' . $output .  ' in ' . $elapsed . 's');
        }
    }
public static function run ( ) { foreach ( Orm \ CmsCronQuery :: active ( ) -> find ( ) as $ cron ) { if ( ! self :: _getToExecute ( $ cron ) ) { continue ; } $ output = '' ; try { $ start = microtime ( true ) ; $ output = \ Mmi \ Mvc \ ActionHelper :: getInstance ( ) -> action ( new \ Mmi \ Http \ Request ( [ 'module' => $ cron -> module , 'controller' => $ cron -> controller , 'action' => $ cron -> action ] ) ) ; $ elapsed = round ( microtime ( true ) - $ start , 2 ) ; } catch ( \ Exception $ e ) { //error logging \ Mmi \ App \ FrontController :: getInstance ( ) -> getLogger ( ) -> error ( 'CRON failed: @' . gethostname ( ) . $ cron -> name . ' ' . $ e -> getMessage ( ) ) ; return ; } //zmień datę ostatniego wywołania $ cron -> dateLastExecute = date ( 'Y-m-d H:i:s' ) ; //ponowne łączenie \ App \ Registry :: $ db -> connect ( ) ; //zapis do bazy bez modyfikowania daty ostatniej modyfikacji $ cron -> saveWithoutLastDateModify ( ) ; //logowanie uruchomienia \ Mmi \ App \ FrontController :: getInstance ( ) -> getLogger ( ) -> info ( 'CRON done: @' . gethostname ( ) . ' ' . $ cron -> name . ' ' . $ output . ' in ' . $ elapsed . 's' ) ; } }
Pobiera zadania crona
Pobiera zadania crona