Changeset 7319
- Timestamp:
- 02/04/08 12:10:08 (10 months ago)
- Files:
-
- plugins/sfJobQueuePlugin/trunk/config/schema.yml (modified) (1 diff)
- plugins/sfJobQueuePlugin/trunk/lib/jobHandlers/sfJobHandler.class.php (modified) (1 diff)
- plugins/sfJobQueuePlugin/trunk/lib/model/sfJob.php (modified) (5 diffs)
- plugins/sfJobQueuePlugin/trunk/lib/model/sfJobQueue.php (modified) (15 diffs)
- plugins/sfJobQueuePlugin/trunk/lib/schedulers/sfScheduler.class.php (modified) (3 diffs)
- plugins/sfJobQueuePlugin/trunk/modules/sfJob/config/generator.yml (modified) (2 diffs)
- plugins/sfJobQueuePlugin/trunk/modules/sfJob/templates/_is_recuring.php (modified) (1 diff)
- plugins/sfJobQueuePlugin/trunk/modules/sfJob/templates/_tries.php (modified) (1 diff)
- plugins/sfJobQueuePlugin/trunk/modules/sfJobQueue/config/generator.yml (modified) (2 diffs)
- plugins/sfJobQueuePlugin/trunk/modules/sfJobQueue/templates/_list_th_tabular2.php (modified) (1 diff)
- plugins/sfJobQueuePlugin/trunk/modules/sfJobQueue/templates/_nb_active_recurring_jobs.php (moved) (moved from plugins/sfJobQueuePlugin/trunk/modules/sfJobQueue/templates/_nb_active_recuring_jobs.php) (1 diff)
- plugins/sfJobQueuePlugin/trunk/package.xml (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/sfJobQueuePlugin/trunk/config/schema.yml
r7251 r7319 11 11 tries: integer 12 12 max_tries: integer 13 is_recur ing:boolean13 is_recurring: boolean 14 14 # retry delay, in seconds (minimal delay between two tries of the same job) 15 15 retry_delay: integer plugins/sfJobQueuePlugin/trunk/lib/jobHandlers/sfJobHandler.class.php
r7251 r7319 72 72 public function setSfJob(sfJob $sf_job) 73 73 { 74 $sf_propel_job_logger = $this->logger->getLogger('sfPropelJobLogger'); 74 if (sfConfig::get('app_sfJobQueuePlugin_logging_enabled', true) === true) 75 { 76 $sf_propel_job_logger = $this->logger->getLogger('sfPropelJobLogger'); 75 77 76 if (is_null($sf_propel_job_logger)) 77 { 78 $sf_propel_job_logger = new sfPropelJobLogger(); 78 if (is_null($sf_propel_job_logger)) 79 { 80 $sf_propel_job_logger = new sfPropelJobLogger(); 81 } 82 83 $sf_propel_job_logger->initialize(array('sf_job_id' => $sf_job->getId())); 84 $this->logger->registerLogger($sf_propel_job_logger); 79 85 } 80 81 $sf_propel_job_logger->initialize(array('sf_job_id' => $sf_job->getId()));82 $this->logger->registerLogger($sf_propel_job_logger);83 86 } 84 87 } plugins/sfJobQueuePlugin/trunk/lib/model/sfJob.php
r7251 r7319 60 60 } 61 61 62 if (isset($options['is_recur ing']))63 { 64 $this->setIsRecur ing($options['is_recuring']);65 unset($options['is_recur ing']);62 if (isset($options['is_recurring'])) 63 { 64 $this->setIsRecurring($options['is_recurring']); 65 unset($options['is_recurring']); 66 66 } 67 67 … … 73 73 else 74 74 { 75 $max_tries = sfConfig::get('app_sfJobQueue _max_tries', 3);75 $max_tries = sfConfig::get('app_sfJobQueuePlugin_max_tries', 3); 76 76 $this->setMaxTries($max_tries); 77 77 } … … 131 131 catch (Exception $e) 132 132 { 133 if (!$this->getIsRecur ing())133 if (!$this->getIsRecurring()) 134 134 { 135 135 $status = self::ERROR; … … 142 142 } 143 143 144 if (!$this->getIsRecur ing())144 if (!$this->getIsRecurring()) 145 145 { 146 146 if (($this->getTries() >= $this->getMaxTries()) … … 210 210 211 211 // Max number of tries reached, change status to "error" 212 if (!$this->getIsRecur ing()212 if (!$this->getIsRecurring() 213 213 && ($this->getTries() >= $this->getMaxTries())) 214 214 { plugins/sfJobQueuePlugin/trunk/lib/model/sfJobQueue.php
r6878 r7319 2 2 /* 3 3 * This file is part of the sfJobQueuePlugin package. 4 * 4 * 5 5 * (c) 2007 Xavier Lacot <xavier@lacot.org> 6 * 6 * 7 7 * For the full copyright and license information, please view the LICENSE 8 8 * file that was distributed with this source code. … … 10 10 11 11 /** 12 * This plugins enables job queues into Symfony. It includes all the common job 13 * queues tasks (start, stop, scheduling through job election strategies, etc.), 14 * command line tasks, and a graphical interface for managing queues and jobs. 15 * Using a job queue can be useful when asynchronised server-side operations 16 * have to be performed (periodically grabbing a RSS feed, automatically sending 12 * This plugins enables job queues into Symfony. It includes all the common job 13 * queues tasks (start, stop, scheduling through job election strategies, etc.), 14 * command line tasks, and a graphical interface for managing queues and jobs. 15 * Using a job queue can be useful when asynchronised server-side operations 16 * have to be performed (periodically grabbing a RSS feed, automatically sending 17 17 * emails, etc.) or in environments without a cron access. 18 * 18 * 19 19 * @author Xavier Lacot <xavier@lacot.org> 20 20 * @see http://www.symfony-project.com/trac/wiki/sfJobQueuePlugin … … 32 32 const SUCCESS = 'success'; 33 33 34 public static $status_text = array(self::STOPPED => 'stopped', 34 public static $status_text = array(self::STOPPED => 'stopped', 35 35 self::RUNNING => 'running'); 36 36 … … 42 42 /** 43 43 * Creates a new job in the queue 44 * 44 * 45 45 * @param string type of the job 46 46 * @param array options of the job 47 * 47 * 48 48 * @return object created job 49 49 */ … … 64 64 /** 65 65 * Returns the number of jobs to be done 66 * 66 * 67 67 * @return integer 68 68 */ … … 81 81 } 82 82 83 public function getNbActiveRecur ingJobs()83 public function getNbActiveRecurringJobs() 84 84 { 85 85 $c = new Criteria(); 86 86 $c->add(sfJobPeer::SF_JOB_QUEUE_ID, $this->getId()); 87 87 $c->add(sfJobPeer::STATUS, array(sfJob::RUNNING, sfJob::IDLE, sfJob::STOPPED), Criteria::IN); 88 $c->add(sfJobPeer::IS_RECUR ING, 1);88 $c->add(sfJobPeer::IS_RECURRING, 1); 89 89 return sfJobPeer::doCount($c); 90 90 } … … 106 106 /** 107 107 * Returns the number of cancelled jobs 108 * 108 * 109 109 * @return integer 110 110 */ … … 119 119 /** 120 120 * Returns the number of jobs completed on failure 121 * 121 * 122 122 * @return integer 123 123 */ … … 132 132 /** 133 133 * Returns the number of completed jobs 134 * 134 * 135 135 * @return integer 136 136 */ … … 145 145 /** 146 146 * Returns the number of jobs completed on success 147 * 147 * 148 148 * @return integer 149 149 */ … … 158 158 /** 159 159 * Gets the current status of the queue from the database 160 * 160 * 161 161 * @return integer 162 162 */ … … 169 169 /** 170 170 * Returns the status of the queue, as a text 171 * 171 * 172 172 * @return string 173 173 */ … … 192 192 /** 193 193 * Indicates whether the queue is running or not 194 * 194 * 195 195 * @return boolean 196 196 */ … … 232 232 } 233 233 234 $this->logger->log(sprintf('Queue "%s" stopped.', 234 $this->logger->log(sprintf('Queue "%s" stopped.', 235 235 $this->getName())); 236 236 $this->setStatus(self::STOPPED); … … 239 239 catch (Exception $e) 240 240 { 241 $this->logger->log(sprintf('Queue "%s" unexpect idly stopped on error "%s"',241 $this->logger->log(sprintf('Queue "%s" unexpectedly stopped on error "%s"', 242 242 $this->getName(), 243 243 $e->getMessage())); plugins/sfJobQueuePlugin/trunk/lib/schedulers/sfScheduler.class.php
r5658 r7319 2 2 /* 3 3 * This file is part of the sfJobQueuePlugin package. 4 * 4 * 5 5 * (c) 2007 Xavier Lacot <xavier@lacot.org> 6 * 6 * 7 7 * For the full copyright and license information, please view the LICENSE 8 8 * file that was distributed with this source code. … … 21 21 { 22 22 $query = ' 23 SELECT * 23 SELECT * 24 24 FROM %s 25 25 WHERE %s = ? … … 32 32 $query = sprintf($query, 33 33 sfJobPeer::TABLE_NAME, 34 sfJobPeer::SF_JOB_QUEUE_ID, 34 sfJobPeer::SF_JOB_QUEUE_ID, 35 35 sfJobPeer::TRIES, 36 36 sfJobPeer::MAX_TRIES, 37 sfJobPeer::IS_RECUR ING,37 sfJobPeer::IS_RECURRING, 38 38 sfJobPeer::COMPLETED_AT, 39 39 sfJobPeer::STATUS, plugins/sfJobQueuePlugin/trunk/modules/sfJob/config/generator.yml
r7260 r7319 18 18 filters: [type, status, sf_job_queue_id] 19 19 sort: [created_at, desc] 20 display: [sf_job_queue, =type, =name, _status, _tries, _is_recur ing, created_at, scheduled_at, _last_tried_at, completed_at]20 display: [sf_job_queue, =type, =name, _status, _tries, _is_recurring, created_at, scheduled_at, _last_tried_at, completed_at] 21 21 object_actions: 22 22 _edit: - … … 30 30 title: Job edition 31 31 display: 32 "Job informations": [sf_job_queue_id, _type, name, max_tries, is_recur ing, retry_delay, scheduled_at]32 "Job informations": [sf_job_queue_id, _type, name, max_tries, is_recurring, retry_delay, scheduled_at] 33 33 "Job parameters": [_params] 34 34 "Job status": [status, tries, created_at, last_tried_at, completed_at] plugins/sfJobQueuePlugin/trunk/modules/sfJob/templates/_is_recuring.php
r5658 r7319 1 <?php if ($sf_job->getIsRecur ing()): ?>1 <?php if ($sf_job->getIsRecurring()): ?> 2 2 <?php echo image_tag('/sf/sf_admin/images/save.png') ?> 3 3 <?php else: ?> plugins/sfJobQueuePlugin/trunk/modules/sfJob/templates/_tries.php
r5658 r7319 1 <?php echo $sf_job->getTries(); ?><?php if (!$sf_job->getIsRecur ing()): ?> / <?php echo $sf_job->getMaxTries(); ?><?php endif; ?>1 <?php echo $sf_job->getTries(); ?><?php if (!$sf_job->getIsRecurring()): ?> / <?php echo $sf_job->getMaxTries(); ?><?php endif; ?> plugins/sfJobQueuePlugin/trunk/modules/sfJobQueue/config/generator.yml
r7260 r7319 12 12 _nb_active_ready_jobs: { name: ready, help: number of jobs ready to be executed } 13 13 _nb_active_waiting_jobs: { name: waiting, help: number of waiting jobs } 14 _nb_active_recur ing_jobs: { name: recuring, help: number of recuring jobs }14 _nb_active_recurring_jobs: { name: recurring, help: number of recurring jobs } 15 15 _nb_active_scheduled_jobs: { name: scheduled, help: number of scheduled jobs } 16 16 _nb_active_jobs: { name: scheduled, help: number of active jobs } … … 24 24 filters: [status] 25 25 sort: [created_at, desc] 26 display: [_name, _is_running, created_at, _nb_active_ready_jobs, _nb_active_waiting_jobs, __nb_active_recur ing_jobs, _nb_active_scheduled_jobs, _nb_active_jobs, nb_completed_successful_jobs, _nb_completed_cancelled_jobs, _nb_completed_failure_jobs]26 display: [_name, _is_running, created_at, _nb_active_ready_jobs, _nb_active_waiting_jobs, __nb_active_recurring_jobs, _nb_active_scheduled_jobs, _nb_active_jobs, nb_completed_successful_jobs, _nb_completed_cancelled_jobs, _nb_completed_failure_jobs] 27 27 object_actions: 28 28 _edit: - plugins/sfJobQueuePlugin/trunk/modules/sfJobQueue/templates/_list_th_tabular2.php
r5658 r7319 7 7 <?php echo image_tag(sfConfig::get('sf_admin_web_dir').'/images/help.png', array('align' => 'absmiddle', 'alt' => __('number of waiting jobs'), 'title' => __('number of waiting jobs'))) ?> 8 8 </th> 9 <th id="sf_admin_list_th_nb_active_jobs_recur ing">10 <?php echo __('recur ing') ?>11 <?php echo image_tag(sfConfig::get('sf_admin_web_dir').'/images/help.png', array('align' => 'absmiddle', 'alt' => __('number of recur ing jobs'), 'title' => __('number of recuring jobs'))) ?>9 <th id="sf_admin_list_th_nb_active_jobs_recurring"> 10 <?php echo __('recurring') ?> 11 <?php echo image_tag(sfConfig::get('sf_admin_web_dir').'/images/help.png', array('align' => 'absmiddle', 'alt' => __('number of recurring jobs'), 'title' => __('number of recurring jobs'))) ?> 12 12 </th> 13 13 <th id="sf_admin_list_th_nb_active_jobs_scheduled"> plugins/sfJobQueuePlugin/trunk/modules/sfJobQueue/templates/_nb_active_recurring_jobs.php
r5658 r7319 1 <?php echo $sf_job_queue->getNbActiveRecur ingJobs(); ?>1 <?php echo $sf_job_queue->getNbActiveRecurringJobs(); ?> plugins/sfJobQueuePlugin/trunk/package.xml
r5658 r7319 68 68 <dir name="templates"> 69 69 <file name="_filters.php" role="data" /> 70 <file name="_is_recur ing.php" role="data" />70 <file name="_is_recurring.php" role="data" /> 71 71 <file name="_list_td_actions.php" role="data" /> 72 72 <file name="_params.php" role="data" /> … … 99 99 <file name="_nb_active_jobs.php" role="data" /> 100 100 <file name="_nb_active_ready_jobs.php" role="data" /> 101 <file name="_nb_active_recur ing_jobs.php" role="data" />101 <file name="_nb_active_recurring_jobs.php" role="data" /> 102 102 <file name="_nb_active_scheduled_jobs.php" role="data" /> 103 103 <file name="_nb_active_waiting_jobs.php" role="data" />