Added maintenance mode.

This commit is contained in:
DebaucheryLibrarian 2023-12-06 01:51:34 +01:00
parent a3c064be55
commit 2a3f21976a
4 changed files with 76 additions and 1 deletions

59
assets/maintenance.ejs Normal file
View File

@ -0,0 +1,59 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,height=device-height,initial-scale=1,maximum-scale=1,user-scalable=no">
<meta name="theme-color" content="#ff2288">
<title>traxxx | maintenance</title>
<link rel="icon" href="/img/favicon/favicon-32.ico">
<link rel="icon" href="/img/favicon/favicon.svg" type="image/svg+xml">
<link rel="apple-touch-icon" href="/img/favicon/favicon-180.png">
<link rel="manifest" href="/img/favicon/manifest.webmanifest">
<meta name="msapplication-TileColor" content="#aa2c66">
<meta name="msapplication-config" content="/img/favicon/browserconfig.xml">
<% if (analytics.enabled) { %>
<script async src="<%- analytics.address %>" data-website-id="<%- analytics.siteId %>"></script>
<% } %>
<style>
body,
html {
width: 100%;
height: 100%;
margin: 0;
}
body {
display: flex;
align-items: center;
justify-content: center;
font-family: sans-serif;
background: url('/img/maintenance_ella_reese.jpeg');
background-position: top center;
background-size: cover
}
.text {
padding: 2rem;
margin: 1rem;
color: white;
text-align: center;
text-shadow: 0 0 5px black;
font-size: 1.5rem;
font-weight: bold;
border-radius: 2rem;
backdrop-filter: blur(.5rem);
}
</style>
</head>
<body>
<div class="text">
<%= text %>
</div>
</body>
</html>

View File

@ -36,6 +36,10 @@ module.exports = {
maxAge: 2629800000, // 1 month maxAge: 2629800000, // 1 month
}, },
}, },
maintenance: {
enabled: false,
text: 'Traxxx is currently under maintenance. We will be back shortly!',
},
}, },
redis: { redis: {
host: 'localhost', host: 'localhost',

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 KiB

View File

@ -162,7 +162,19 @@ async function initServer() {
}); });
router.use(errorHandler); router.use(errorHandler);
app.use(router);
if (config.web.maintenance.enabled) {
app.use(express.static('public'));
app.get('/', (req, res) => {
res.status(503).render(path.join(__dirname, '../../assets/maintenance.ejs'), {
analytics: config.analytics,
text: config.web.maintenance.text,
});
});
} else {
app.use(router);
}
const server = app.listen(config.web.port, config.web.host, () => { const server = app.listen(config.web.port, config.web.host, () => {
const { address, port } = server.address(); const { address, port } = server.address();