From e6d781eb4614d9bb8f87133e16c62a1a5a564e77 Mon Sep 17 00:00:00 2001 From: arno Date: Mon, 14 Mar 2011 17:21:55 +0100 Subject: [PATCH] call cron scripts with php cli --- application/Bootstrap.php | 1 - application/configs/application.ini | 4 --- application/controllers/CronController.php | 20 -------------- application/crons/pending.php | 5 ++++ public/index.php | 31 ++-------------------- public/init.php | 28 +++++++++++++++++++ scripts/cron.php | 10 +++++++ scripts/crontab.syj | 2 +- 8 files changed, 46 insertions(+), 55 deletions(-) delete mode 100644 application/controllers/CronController.php create mode 100644 application/crons/pending.php create mode 100644 public/init.php create mode 100755 scripts/cron.php diff --git a/application/Bootstrap.php b/application/Bootstrap.php index 08816c0..5da7d3e 100644 --- a/application/Bootstrap.php +++ b/application/Bootstrap.php @@ -47,4 +47,3 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap { } } - diff --git a/application/configs/application.ini b/application/configs/application.ini index 3c74396..cb9d2cc 100644 --- a/application/configs/application.ini +++ b/application/configs/application.ini @@ -90,10 +90,6 @@ resources.router.routes.pending.defaults.action = "index" resources.router.routes.termsofuse.route = "termsofuse/" resources.router.routes.termsofuse.defaults.controller = "termsofuse" resources.router.routes.termsofuse.defaults.action = "index" -; cron/ -resources.router.routes.cron.route = "cron/" -resources.router.routes.cron.defaults.controller = "cron" -resources.router.routes.cron.defaults.action = "index" ; newpwd/ resources.router.routes.newpwd.route = "newpwd/" resources.router.routes.newpwd.defaults.controller = "newpwd" diff --git a/application/controllers/CronController.php b/application/controllers/CronController.php deleted file mode 100644 index e8ab6ec..0000000 --- a/application/controllers/CronController.php +++ /dev/null @@ -1,20 +0,0 @@ -getRequest()->getClientIp(true); - if ($ip !== '127.0.0.1' and $ip !== '::1') { - throw new Syj_Exception_Forbidden(); - } - } - public function indexAction() { - $mapper = new Syj_Model_PendingMapper(); - foreach ($mapper->fetchAll() as $pending) { - $pending->notify(); - } - $this->_helper->SyjApi->setCode(200); - } -} diff --git a/application/crons/pending.php b/application/crons/pending.php new file mode 100644 index 0000000..fc6d1ab --- /dev/null +++ b/application/crons/pending.php @@ -0,0 +1,5 @@ +fetchAll() as $pending) { + $pending->notify(); +} diff --git a/public/index.php b/public/index.php index f38470e..b2a875f 100644 --- a/public/index.php +++ b/public/index.php @@ -1,32 +1,5 @@ bootstrap() - ->run(); +$application->bootstrap()->run(); diff --git a/public/init.php b/public/init.php new file mode 100644 index 0000000..4780fe3 --- /dev/null +++ b/public/init.php @@ -0,0 +1,28 @@ +bootstrap(); + +foreach (glob(realpath(APPLICATION_PATH . '/crons') . '/*.php') as $fname) { + require_once ($fname); +} diff --git a/scripts/crontab.syj b/scripts/crontab.syj index cf80bef..53159e9 100644 --- a/scripts/crontab.syj +++ b/scripts/crontab.syj @@ -1,6 +1,6 @@ MAILTO=arno@renevier.net # every 5 minutes, call syj php cron -*/5 * * * * /usr/bin/wget --header="Host: osm-syj.crans.org" http://localhost/cron -O /dev/null -o /dev/null +*/5 * * * * /data/project/syj/scripts/cron.php # every month, update geoip db 12 3 3 * * /data/project/syj/scripts/updategeoip.sh # every day, delete old sessions files -- 2.39.2