Changeset 374


Ignore:
Timestamp:
06/25/10 14:15:07 (10 years ago)
Author:
sander
Message:

Automatically disable jobs after a certain number of failures

Location:
trunk/server/www/app
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/server/www/app/config/core.php.default

    r318 r374  
    279279                Configure::write('Job.locktime', (5 * 60)); 
    280280        } 
     281/** 
     282 * The number of times a job is allowed to fail before it will not run again 
     283 */ 
     284        Configure:write('Job.maxfailures', 5); 
    281285/** 
    282286 * The number of seconds since the last poll of a factory before it is dropped from the front page. 
  • trunk/server/www/app/config/sql/schema.php

    r372 r374  
    11<?php  
    22/* SVN FILE: $Id$ */ 
    3 /* App schema generated on: 2010-06-08 12:06:45 : 1275992085*/ 
     3/* App schema generated on: 2010-06-25 14:06:50 : 1277467250*/ 
    44class AppSchema extends CakeSchema { 
    55        var $name = 'App'; 
     
    111111                        'factory_id' => array('type' => 'string', 'null' => false, 'default' => NULL, 'length' => 36), 
    112112                        'state' => array('type' => 'integer', 'null' => false, 'default' => '1'), 
     113                        'failures' => array('type' => 'integer', 'null' => false, 'default' => '0'), 
    113114                        'locked' => array('type' => 'datetime', 'null' => false, 'default' => '0000-00-00 00:00:00'), 
    114115                        'created' => array('type' => 'datetime', 'null' => true, 'default' => NULL), 
  • trunk/server/www/app/controllers/jobs_controller.php

    r373 r374  
    521521                } 
    522522 
     523                // If a factory ID has been set, this job has been handed out earlier. Increase the failure count 
     524                if ($job['Job']['factory_id']) { 
     525                        $job['Job']['failures'] += 1; 
     526 
     527                        // If this job has failed too many times, change it's state and prompt the factory to poll again 
     528                        if ($job['Job']['failures'] > Configure::read('Job.maxfailures')) { 
     529                                $job['Job']['state'] = Job::STATE_FAILED; 
     530                                $this->Job->save($job); 
     531                                 
     532                                $this->log(sprintf("Job ID %s failed %s times. Stopping job.", $job['Job']['id'], Configure::read('Job.maxfailures')), LOG_DEBUG); 
     533                                return null; 
     534                        } 
     535                } 
     536 
    523537                $job['Job']['locked'] = date('Y-m-d H:i:s', time() + Configure::read('Job.locktime')); 
    524538                $job['Job']['factory_id'] = $factory['Factory']['id']; 
Note: See TracChangeset for help on using the changeset viewer.