src/models/CmsAgentModel.php
static public function stopLongExecutable($agentMaxExecuteTime = null)
    {
        if ($agentMaxExecuteTime === null) {
            $agentMaxExecuteTime = \Yii::$app->cmsAgent->agentMaxExecuteTime;
        }

        $time = \Yii::$app->formatter->asTimestamp(time()) - (int)$agentMaxExecuteTime;

        $running = static::find()
            ->where([
                'is_running' => Cms::BOOL_Y
            ])
            ->orderBy('priority')
            ->all();;

        $stoping = 0;

        if ($running) {
            /**
             * @var $agent CmsAgent
             */
            foreach ($running as $agent) {
                if ($agent->next_exec_at <= $time) {
                    if ($agent->stop()) {
                        $stoping++;
                    } else {
                        \Yii::error('Not stopped long agent: ' . $agent->name, 'skeeks/agent');
                    }
                }
            }
        }

        return $stoping;
    }
static public function stopLongExecutable($agentMaxExecuteTime = null)
    {
        if ($agentMaxExecuteTime === null) {
            $agentMaxExecuteTime = \Yii::$app->cmsAgent->agentMaxExecuteTime;
        }

        $time = \Yii::$app->formatter->asTimestamp(time()) - (int)$agentMaxExecuteTime;

        $running = static::find()
            ->where([
                'is_running' => Cms::BOOL_Y
            ])
            ->orderBy('priority')
            ->all();;

        $stoping = 0;

        if ($running) {
            /**
             * @var $agent CmsAgent
             */
            foreach ($running as $agent) {
                if ($agent->next_exec_at <= $time) {
                    if ($agent->stop()) {
                        $stoping++;
                    } else {
                        \Yii::error('Not stopped long agent: ' . $agent->name, 'skeeks/agent');
                    }
                }
            }
        }

        return $stoping;
    }
static public function stopLongExecutable ( $ agentMaxExecuteTime = null ) { if ( $ agentMaxExecuteTime === null ) { $ agentMaxExecuteTime = \ Yii :: $ app -> cmsAgent -> agentMaxExecuteTime ; } $ time = \ Yii :: $ app -> formatter -> asTimestamp ( time ( ) ) - ( int ) $ agentMaxExecuteTime ; $ running = static :: find ( ) -> where ( [ 'is_running' => Cms :: BOOL_Y ] ) -> orderBy ( 'priority' ) -> all ( ) ; ; $ stoping = 0 ; if ( $ running ) { /**
             * @var $agent CmsAgent
             */ foreach ( $ running as $ agent ) { if ( $ agent -> next_exec_at <= $ time ) { if ( $ agent -> stop ( ) ) { $ stoping ++ ; } else { \ Yii :: error ( 'Not stopped long agent: ' . $ agent -> name , 'skeeks/agent' ) ; } } } } return $ stoping ; }
Stop long executable agents

@return int
Stop long executable agents