/** * Attempt to restart a stalled job * * @param QueuedJobDescriptor $stalledJob * @return bool True if the job was successfully restarted */ protected function restartStalledJob($stalledJob) { if ($stalledJob->ResumeCounts < Config::inst()->get(__CLASS__, 'stall_threshold')) { $stalledJob->restart(); $message = sprintf(_t('QueuedJobs.STALLED_JOB_MSG', 'A job named %s appears to have stalled. It will be stopped and restarted, please login to make sure it has continued'), $stalledJob->JobTitle); } else { $stalledJob->pause(); $message = sprintf(_t('QueuedJobs.STALLED_JOB_MSG', 'A job named %s appears to have stalled. It has been paused, please login to check it'), $stalledJob->JobTitle); } singleton('QJUtils')->log($message); $from = Config::inst()->get('Email', 'admin_email'); $to = Config::inst()->get('Email', 'queued_job_admin_email'); $subject = _t('QueuedJobs.STALLED_JOB', 'Stalled job'); $mail = new Email($from, $to, $subject, $message); $mail->send(); }