Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJörn Friedrich Dreyer <jfd@butonic.de>2013-06-10 15:45:19 +0400
committerJörn Friedrich Dreyer <jfd@butonic.de>2013-06-10 15:45:19 +0400
commit8dc6bdd96b9088b87fe8d11346338343135c77e7 (patch)
tree2f969c8b9a0572d7e4648c9ad8ff2524bdaf27af /cron.php
parentc0bdbd9d81eb22ded95cd7ea9b26a0c36cfa1be0 (diff)
clean up usage of DatabaseSetupException and catch Exceptions in entrypoints
Diffstat (limited to 'cron.php')
-rw-r--r--cron.php120
1 files changed, 63 insertions, 57 deletions
diff --git a/cron.php b/cron.php
index 95cedf8bf4c..fbea7f26aed 100644
--- a/cron.php
+++ b/cron.php
@@ -44,75 +44,81 @@ function handleUnexpectedShutdown() {
}
}
-require_once 'lib/base.php';
+try {
-session_write_close();
+ require_once 'lib/base.php';
-// Don't do anything if ownCloud has not been installed
-if (!OC_Config::getValue('installed', false)) {
- exit(0);
-}
-
-// Handle unexpected errors
-register_shutdown_function('handleUnexpectedShutdown');
+ session_write_close();
-// Delete temp folder
-OC_Helper::cleanTmpNoClean();
-
-// Exit if background jobs are disabled!
-$appmode = OC_BackgroundJob::getExecutionType();
-if ($appmode == 'none') {
- TemporaryCronClass::$sent = true;
- if (OC::$CLI) {
- echo 'Background Jobs are disabled!' . PHP_EOL;
- } else {
- OC_JSON::error(array('data' => array('message' => 'Background jobs disabled!')));
+ // Don't do anything if ownCloud has not been installed
+ if (!OC_Config::getValue('installed', false)) {
+ exit(0);
}
- exit(1);
-}
-if (OC::$CLI) {
- // Create lock file first
- TemporaryCronClass::$lockfile = OC_Config::getValue("datadirectory", OC::$SERVERROOT . '/data') . '/cron.lock';
+ // Handle unexpected errors
+ register_shutdown_function('handleUnexpectedShutdown');
- // We call ownCloud from the CLI (aka cron)
- if ($appmode != 'cron') {
- // Use cron in feature!
- OC_BackgroundJob::setExecutionType('cron');
- }
+ // Delete temp folder
+ OC_Helper::cleanTmpNoClean();
- // check if backgroundjobs is still running
- if (file_exists(TemporaryCronClass::$lockfile)) {
- TemporaryCronClass::$keeplock = true;
+ // Exit if background jobs are disabled!
+ $appmode = OC_BackgroundJob::getExecutionType();
+ if ($appmode == 'none') {
TemporaryCronClass::$sent = true;
- echo "Another instance of cron.php is still running!";
+ if (OC::$CLI) {
+ echo 'Background Jobs are disabled!' . PHP_EOL;
+ } else {
+ OC_JSON::error(array('data' => array('message' => 'Background jobs disabled!')));
+ }
exit(1);
}
- // Create a lock file
- touch(TemporaryCronClass::$lockfile);
+ if (OC::$CLI) {
+ // Create lock file first
+ TemporaryCronClass::$lockfile = OC_Config::getValue("datadirectory", OC::$SERVERROOT . '/data') . '/cron.lock';
- // Work
- $jobList = new \OC\BackgroundJob\JobList();
- $jobs = $jobList->getAll();
- foreach ($jobs as $job) {
- $job->execute($jobList);
- }
-} else {
- // We call cron.php from some website
- if ($appmode == 'cron') {
- // Cron is cron :-P
- OC_JSON::error(array('data' => array('message' => 'Backgroundjobs are using system cron!')));
- } else {
- // Work and success :-)
+ // We call ownCloud from the CLI (aka cron)
+ if ($appmode != 'cron') {
+ // Use cron in feature!
+ OC_BackgroundJob::setExecutionType('cron');
+ }
+
+ // check if backgroundjobs is still running
+ if (file_exists(TemporaryCronClass::$lockfile)) {
+ TemporaryCronClass::$keeplock = true;
+ TemporaryCronClass::$sent = true;
+ echo "Another instance of cron.php is still running!";
+ exit(1);
+ }
+
+ // Create a lock file
+ touch(TemporaryCronClass::$lockfile);
+
+ // Work
$jobList = new \OC\BackgroundJob\JobList();
- $job = $jobList->getNext();
- $job->execute($jobList);
- $jobList->setLastJob($job);
- OC_JSON::success();
+ $jobs = $jobList->getAll();
+ foreach ($jobs as $job) {
+ $job->execute($jobList);
+ }
+ } else {
+ // We call cron.php from some website
+ if ($appmode == 'cron') {
+ // Cron is cron :-P
+ OC_JSON::error(array('data' => array('message' => 'Backgroundjobs are using system cron!')));
+ } else {
+ // Work and success :-)
+ $jobList = new \OC\BackgroundJob\JobList();
+ $job = $jobList->getNext();
+ $job->execute($jobList);
+ $jobList->setLastJob($job);
+ OC_JSON::success();
+ }
}
-}
-// done!
-TemporaryCronClass::$sent = true;
-exit();
+ // done!
+ TemporaryCronClass::$sent = true;
+ exit();
+
+} catch (Exception $ex) {
+ \OCP\Util::writeLog('cron', $ex->getMessage(), \OCP\Util::FATAL);
+} \ No newline at end of file