]> git.mxchange.org Git - friendica.git/commitdiff
dbstructure now switches in the maintenance mode when updating
authorMichael Vogel <ike@pirati.ca>
Sun, 2 Oct 2016 13:52:52 +0000 (13:52 +0000)
committerMichael Vogel <ike@pirati.ca>
Sun, 2 Oct 2016 13:52:52 +0000 (13:52 +0000)
include/dbstructure.php
include/poller.php
mod/maintenance.php

index 0c933c6648d9a0242912842c6cfa108b0675708c..6224b434d819cb5267d34478d45e028661dadd1c 100644 (file)
@@ -126,6 +126,9 @@ function print_structure($database, $charset) {
 function update_structure($verbose, $action, $tables=null, $definition=null) {
        global $a, $db;
 
+       if ($action)
+               set_config('system', 'maintenance', 1);
+
        if (isset($a->config["system"]["db_charset"]))
                $charset = $a->config["system"]["db_charset"];
        else
@@ -241,6 +244,9 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
                }
        }
 
+       if ($action)
+               set_config('system', 'maintenance', 0);
+
        return $errors;
 }
 
index ce2a6be0fa62a1c9c1cccd2b8fd297f77bb9f39d..fe4d4245af8df0a3a3d6fc4c6f94accbe2c5e7b5 100644 (file)
@@ -29,6 +29,10 @@ function poller_run(&$argv, &$argc){
                unset($db_host, $db_user, $db_pass, $db_data);
        };
 
+       // Quit when in maintenance
+       if (get_config('system', 'maintenance', true))
+               return;
+
        $a->start_process();
 
        $mypid = getmypid();
@@ -71,6 +75,10 @@ function poller_run(&$argv, &$argc){
 
        while ($r = q("SELECT * FROM `workerqueue` WHERE `executed` = '0000-00-00 00:00:00' ORDER BY `priority`, `created` LIMIT 1")) {
 
+               // Quit when in maintenance
+               if (get_config('system', 'maintenance', true))
+                       return;
+
                // Constantly check the number of parallel database processes
                if ($a->max_processes_reached())
                        return;
index b50c94c9b93d9a6acb748cea3d3da6a680041ec1..3d21ce40b759d6b28e7b51e8396daf9bcc91aee6 100644 (file)
@@ -1,6 +1,10 @@
 <?php
 
 function maintenance_content(&$a) {
+       header('HTTP/1.1 503 Service Temporarily Unavailable');
+       header('Status: 503 Service Temporarily Unavailable');
+       header('Retry-After: 600');
+
        return replace_macros(get_markup_template('maintenance.tpl'), array(
                '$sysdown' => t('System down for maintenance')
        ));