Index: admin_templates/agents/agent_edit.tpl =================================================================== --- admin_templates/agents/agent_edit.tpl (revision 14667) +++ admin_templates/agents/agent_edit.tpl (working copy) @@ -1,4 +1,4 @@ - + @@ -82,7 +82,8 @@ - + + Index: install/english.lang =================================================================== --- install/english.lang (revision 14667) +++ install/english.lang (working copy) @@ -445,6 +445,7 @@ TGFzdCBOYW1l TGFzdCBSdW4gT24= TGFzdCBSdW4gU3RhdHVz + TGFzdCBUaW1lb3V0IE9u TGFzdCBVcGRhdGVkIE9u TGVmdA== TGluZSBlbmRpbmdz @@ -586,6 +587,7 @@ VGhlc2F1cnVzIFR5cGU= VGhvdXNhbmRzIFNlcGFyYXRvcg== VGltZSBGb3JtYXQ= + VGltZW91dA== VGl0bGU= VG8= VG8gRS1tYWls Index: install/install_schema.sql =================================================================== --- install/install_schema.sql (revision 14667) +++ install/install_schema.sql (working copy) @@ -673,6 +673,8 @@ LastRunStatus tinyint(3) unsigned NOT NULL default '1', NextRunOn int(11) default NULL, RunTime int(10) unsigned NOT NULL default '0', + Timeout int(10) unsigned NOT NULL , + LastTimeoutOn int(10) unsigned default NULL , SiteDomainLimitation varchar(255) NOT NULL, PRIMARY KEY (AgentId), KEY Status (Status), @@ -683,6 +685,7 @@ KEY LastRunStatus (LastRunStatus), KEY RunTime (RunTime), KEY NextRunOn (NextRunOn), + KEY Timeout (Timeout), KEY SiteDomainLimitation (SiteDomainLimitation) ); Index: install/upgrades.sql =================================================================== --- install/upgrades.sql (revision 14667) +++ install/upgrades.sql (working copy) @@ -2154,3 +2154,9 @@ INSERT INTO Permissions VALUES (DEFAULT, 'in-portal:permission_types.add', 11, 1, 1, 0); INSERT INTO Permissions VALUES (DEFAULT, 'in-portal:permission_types.edit', 11, 1, 1, 0); INSERT INTO Permissions VALUES (DEFAULT, 'in-portal:permission_types.delete', 11, 1, 1, 0); + +ALTER TABLE Agents + ADD Timeout int(10) UNSIGNED NOT NULL AFTER RunTime, + ADD LastTimeoutOn int(10) unsigned default NULL AFTER Timeout, + ADD INDEX ( Timeout ); + \ No newline at end of file Index: kernel/managers/agent_manager.php =================================================================== --- kernel/managers/agent_manager.php (revision 14667) +++ kernel/managers/agent_manager.php (working copy) @@ -79,7 +79,10 @@ if ( !isset($agents) ) { $sql = 'SELECT * FROM ' . $this->Application->getUnitOption('agent', 'TableName') . ' - WHERE Status = ' . STATUS_ACTIVE . ' AND LastRunStatus <> ' . Agent::LAST_RUN_RUNNING; + WHERE Status = ' . STATUS_ACTIVE . ' AND ( + LastRunStatus != ' . Agent::LAST_RUN_RUNNING . ' OR + ( LastRunStatus = ' . Agent::LAST_RUN_RUNNING . ' AND Timeout > 0 AND NOW() - LastRunOn > Timeout ) + )'; $all_agents = $this->Conn->Query($sql); $agents = Array ( @@ -94,6 +97,7 @@ 'LastRunOn' => (int)$agent_data['LastRunOn'], 'NextRunOn' => (int)$agent_data['NextRunOn'], 'Status' => $agent_data['Status'], + 'LastRunStatus' => $agent_data['LastRunStatus'], 'SiteDomainLimitation' => $agent_data['SiteDomainLimitation'], ); } @@ -137,7 +141,7 @@ } /** - * Run registred agents with specified event type + * Run registered agents with specified event type * * @param int $event_type * @param bool $from_cron @@ -213,6 +217,11 @@ 'NextRunOn' => $start_time + $agent_data['RunInterval'], ); + // remember LastTimeoutOn only for events that are still running and will be reset + if ( $agent_data['LastRunStatus'] == Agent::LAST_RUN_RUNNING ) { + $fields_hash['LastTimeoutOn'] = $start_time; + } + $this->Conn->doUpdate( $fields_hash, $this->Application->getUnitOption('agent', 'TableName'), Index: units/agents/agent_eh.php =================================================================== --- units/agents/agent_eh.php (revision 14667) +++ units/agents/agent_eh.php (working copy) @@ -121,7 +121,7 @@ } /** - * Cancels agents, that are currenty running + * Cancels agents, that are currently running * * @param kEvent $event */ Index: units/agents/agents_config.php =================================================================== --- units/agents/agents_config.php (revision 14667) +++ units/agents/agents_config.php (working copy) @@ -133,6 +133,8 @@ 'NextRunOn' => Array ('type' => 'int', 'formatter' => 'kDateFormatter', 'required' => 1, 'default' => '#NOW#'), 'RunTime' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0), + 'Timeout' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0), + 'LastTimeoutOn' => Array ('type' => 'int', 'formatter' => 'kDateFormatter', 'default' => NULL), 'SiteDomainLimitation' => Array ( 'type' => 'string', 'max_len' => 255, 'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'SiteDomains ORDER BY DomainName ASC', 'option_key_field' => 'DomainId', 'option_title_field' => 'DomainName', 'multiple' => 1, @@ -158,6 +160,8 @@ 'LastRunStatus' => Array ('filter_block' => 'grid_options_filter', 'width' => 120, ), 'NextRunOn' => Array ('filter_block' => 'grid_date_range_filter', 'width' => 145, ), 'Status' => Array ('filter_block' => 'grid_options_filter', 'width' => 65, ), + 'Timeout' => Array ('filter_block' => 'grid_range_filter', 'width' => 85, ), + 'LastTimeoutOn' => Array ('filter_block' => 'grid_date_range_filter', 'width' => 145, ), 'SiteDomainLimitation' => Array ('data_block' => 'grid_picker_td', 'filter_block' => 'grid_multioptions_filter', 'separator' => ', ', 'width' => 145), ), ),