maintenance
This commit is contained in:
parent
ebdece7144
commit
536cae7a90
31
cli.php
31
cli.php
@ -38,7 +38,7 @@ function connectDatabase() {
|
||||
}
|
||||
|
||||
function printHelp() {
|
||||
|
||||
// TODO: help
|
||||
}
|
||||
|
||||
function handleDatabase($argv) {
|
||||
@ -155,6 +155,31 @@ function handleDatabase($argv) {
|
||||
|
||||
proc_close($process);
|
||||
}
|
||||
} else {
|
||||
die("Usage: cli.php db <migrate|import|export> [options...]");
|
||||
}
|
||||
}
|
||||
|
||||
function onMaintenance($argv) {
|
||||
$action = $argv[2] ?? "status";
|
||||
$maintenanceFile = "MAINTENANCE";
|
||||
$isMaintenanceEnabled = file_exists($maintenanceFile);
|
||||
|
||||
if ($action === "status") {
|
||||
die("Maintenance: " . ($isMaintenanceEnabled ? "on" : "off") . "\n");
|
||||
} else if ($action === "on") {
|
||||
$file = fopen($maintenanceFile, 'w') or die("Unable to create maintenance file\n");
|
||||
fclose($file);
|
||||
die("Maintenance enabled\n");
|
||||
} else if ($action === "off") {
|
||||
if (file_exists($maintenanceFile)) {
|
||||
if (!unlink($maintenanceFile)) {
|
||||
die("Unable to delete maintenance file\n");
|
||||
}
|
||||
}
|
||||
die("Maintenance disabled\n");
|
||||
} else {
|
||||
die("Usage: cli.php maintenance <status|on|off>\n");
|
||||
}
|
||||
}
|
||||
|
||||
@ -172,6 +197,10 @@ switch ($command) {
|
||||
handleDatabase($argv);
|
||||
break;
|
||||
case 'routes':
|
||||
// TODO: routes
|
||||
break;
|
||||
case 'maintenance':
|
||||
onMaintenance($argv);
|
||||
break;
|
||||
default:
|
||||
echo "Unknown command '$command'\n\n";
|
||||
|
BIN
img/maintenance.png
Normal file
BIN
img/maintenance.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 46 KiB |
15
index.php
15
index.php
@ -1,14 +1,21 @@
|
||||
<?php
|
||||
|
||||
include_once 'core/core.php';
|
||||
include_once 'core/datetime.php';
|
||||
include_once 'core/constants.php';
|
||||
|
||||
if (is_file("MAINTENANCE")) {
|
||||
http_response_code(503);
|
||||
$currentDir = dirname(__FILE__);
|
||||
serveStatic($currentDir, "/static/maintenance.html");
|
||||
die();
|
||||
}
|
||||
|
||||
use Api\Request;
|
||||
use Configuration\Configuration;
|
||||
use Documents\Document404;
|
||||
use Elements\Document;
|
||||
|
||||
include_once 'core/core.php';
|
||||
include_once 'core/datetime.php';
|
||||
include_once 'core/constants.php';
|
||||
|
||||
if (!is_readable(getClassPath(Configuration::class))) {
|
||||
header("Content-Type: application/json");
|
||||
die(json_encode(array( "success" => false, "msg" => "Configuration directory is not readable, check permissions before proceeding." )));
|
||||
|
36
static/maintenance.html
Normal file
36
static/maintenance.html
Normal file
@ -0,0 +1,36 @@
|
||||
<!DOCTYPE html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="format-detection" content="telephone=yes">
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="expires" content="0">
|
||||
<meta name="robots" content="noarchive">
|
||||
<title>Maintenance</title>
|
||||
<link rel="stylesheet" href="/css/bootstrap.min.css" type="text/css">
|
||||
<script type="text/javascript" src="/js/bootstrap.bundle.min.js"></script>
|
||||
<link rel="stylesheet" href="/css/fontawesome.min.css" type="text/css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container mt-5">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="error-template pt-5 pl-5">
|
||||
<h1>Service unavailable</h1>
|
||||
<h3>Temporarily down for maintenance</h3>
|
||||
<div>
|
||||
<p>
|
||||
Sorry for the inconvenience but we're performing some maintenance at the moment.
|
||||
we'll be back online shortly!
|
||||
</p>
|
||||
</div>
|
||||
<a href="javascript:document.location.reload()" class="btn btn-info btn-lg mt-3">
|
||||
<i class="fa fa-redo mr-2"></i>Retry
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 text-center pt-5">
|
||||
<img src="/img/maintenance.png" alt="[maintenance]">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
Loading…
Reference in New Issue
Block a user