mirror of
https://github.com/nextcloud/server.git
synced 2026-06-08 16:26:59 -04:00
Backgroundjobs: Improve error handling in cron.php
This commit is contained in:
parent
a6a1f892f0
commit
66511469e0
1 changed files with 16 additions and 0 deletions
16
cron.php
16
cron.php
|
|
@ -20,11 +20,26 @@
|
|||
*
|
||||
*/
|
||||
|
||||
function handleCliShutdown() {
|
||||
$error = error_get_last();
|
||||
if($error !== NULL){
|
||||
echo 'Unexpected error!'.PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
function handleWebShutdown(){
|
||||
$error = error_get_last();
|
||||
if($error !== NULL){
|
||||
OC_JSON::error( array( 'data' => array( 'message' => 'Unexpected error!')));
|
||||
}
|
||||
}
|
||||
|
||||
$RUNTIME_NOSETUPFS = true;
|
||||
require_once('lib/base.php');
|
||||
|
||||
$appmode = OC_Appconfig::getValue( 'core', 'backgroundjobs_mode', 'ajax' );
|
||||
if( OC::$CLI ){
|
||||
register_shutdown_function('handleCliShutdown');
|
||||
if( $appmode != 'cron' ){
|
||||
OC_Appconfig::setValue( 'core', 'backgroundjobs_mode', 'cron' );
|
||||
}
|
||||
|
|
@ -41,6 +56,7 @@ if( OC::$CLI ){
|
|||
OC_BackgroundJob_Worker::doAllSteps();
|
||||
}
|
||||
else{
|
||||
register_shutdown_function('handleWebShutdown');
|
||||
if( $appmode == 'cron' ){
|
||||
OC_JSON::error( array( 'data' => array( 'message' => 'Backgroundjobs are using system cron!')));
|
||||
exit();
|
||||
|
|
|
|||
Loading…
Reference in a new issue