Exemplo n.º 1
0
 /**
  * Save newscoop cronjobs in user cronjob file
  *
  * @param  SchedulerService $scheduler Cron job scheduler service
  * @return bolean
  */
 public function saveCronjobs(SchedulerServiceInterface $scheduler)
 {
     $binDirectory = realpath($this->newscoopDir . '/bin');
     $appDirectory = realpath($this->newscoopDir . '/application/console');
     $scheduler->registerJob("Autopublish pending issues and articles", array('command' => $binDirectory . '/newscoop-autopublish', 'schedule' => '* * * * *'));
     $scheduler->registerJob("Runs Newscoop Indexer - articles indexing", array('command' => $binDirectory . '/newscoop-indexer --silent', 'schedule' => '0 */4 * * *'));
     $scheduler->registerJob("Send Newscoop subscriptions notifications", array('command' => $binDirectory . '/subscription-notifier', 'schedule' => '0 */8 * * *'));
     $scheduler->registerJob("Send Newscoop events notifications", array('command' => $binDirectory . '/events-notifier', 'schedule' => '*/2 * * * *'));
     $scheduler->registerJob("Remove old statistics from Newscoop database", array('command' => $binDirectory . '/newscoop-statistics', 'schedule' => '0 */4 * * *'));
     $scheduler->registerJob("Send Newscoop stats to Sourcefabric", array('command' => $binDirectory . '/newscoop-stats', 'schedule' => '0 5 * * *'));
     $scheduler->registerJob("Remove obsolete pending users data", array('command' => $appDirectory . ' user:garbage', 'schedule' => '30 0 * * *'));
     $scheduler->registerJob("Display the last 7 days logged actions when going to Configure -> Logs. All the rest are stored in newscoop-audit.log.", array('command' => $appDirectory . ' log:maintenance', 'schedule' => '30 1 * * *', 'enabled' => false, 'detailsUrl' => 'http://sourcefabric.booktype.pro/newscoop-42-for-journalists-and-editors/log-file-maintenance/'));
     $crontab = new Crontab();
     $job = new Job();
     $job->setMinute('*')->setHour('*')->setDayOfMonth('*')->setMonth('*')->setDayOfWeek('*')->setCommand('php ' . $appDirectory . ' scheduler:run');
     $crontab->addJob($job);
     $crontab->write();
     return true;
 }