mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 21:15:14 +00:00
Bring back maintenance mode. I personally dislike this because when things go wrong you have to know that you need to disable maintenance mode manually and people never discover this until they are locked out of their sites and panicking. But we absolutely need a way to shut down server activity so we can work on it.
This commit is contained in:
parent
10a99bad49
commit
30889b590f
3 changed files with 47 additions and 0 deletions
|
@ -19,6 +19,9 @@ if (array_search( __file__ , get_included_files()) === 0) {
|
||||||
class Run {
|
class Run {
|
||||||
|
|
||||||
static public function Summon($arr) {
|
static public function Summon($arr) {
|
||||||
|
if (file_exists('maintenance_lock') || file_exists('cache/maintenance_lock')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
proc_run('php','Zotlabs/Daemon/Run.php',$arr);
|
proc_run('php','Zotlabs/Daemon/Run.php',$arr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,10 @@ class WebServer {
|
||||||
|
|
||||||
require_once('boot.php');
|
require_once('boot.php');
|
||||||
|
|
||||||
|
if (file_exists('maintenance_lock') || file_exists('cache/maintenance_lock')) {
|
||||||
|
http_status_exit(503,'System unavailable');
|
||||||
|
}
|
||||||
|
|
||||||
sys_boot();
|
sys_boot();
|
||||||
|
|
||||||
|
|
||||||
|
|
40
util/maintenance
Executable file
40
util/maintenance
Executable file
|
@ -0,0 +1,40 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# enable, disable or check the maintenance mode.
|
||||||
|
# If enabled, web access and execution of background tasks are blocked.
|
||||||
|
# Interaction with the server is only possible through foreground scripts
|
||||||
|
# We look for the existence of two files: maintenance_lock and cache/maintenance_lock
|
||||||
|
# and if either exist the system is locked. We attempt to create and remove both of these.
|
||||||
|
# One or the other _may_ fail due to permissions or ownership issues but the other will
|
||||||
|
# usually succeed.
|
||||||
|
|
||||||
|
if [ $# -ne 0 ]; then
|
||||||
|
action=$1
|
||||||
|
else
|
||||||
|
if [ -f maintenance_lock -o -f cache/maintenance_lock ]; then
|
||||||
|
echo "Maintenance mode is enabled"
|
||||||
|
else
|
||||||
|
echo "Maintenance mode is disabled"
|
||||||
|
fi
|
||||||
|
echo Usage: $0 'on|off'
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $1 == 'on' ]; then
|
||||||
|
touch maintenance_lock > /dev/null 2>&1
|
||||||
|
touch cache/maintenance_lock > /dev/null 2>&1
|
||||||
|
if [ -f maintenance_lock -o -f cache/maintenance_lock ]; then
|
||||||
|
echo "Maintenance mode is enabled"
|
||||||
|
else
|
||||||
|
echo "Failed: Maintenance mode is disabled"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [ $1 == 'off' ]; then
|
||||||
|
rm maintenance_lock > /dev/null 2>&1
|
||||||
|
rm cache/maintenance_lock > /dev/null 2>&1
|
||||||
|
if [ -f maintenance_lock -o -f cache/maintenance_lock ]; then
|
||||||
|
echo "Failed: Maintenance mode is enabled"
|
||||||
|
else
|
||||||
|
echo "Maintenance mode is disabled"
|
||||||
|
fi
|
||||||
|
fi
|
Loading…
Reference in a new issue