A maintenance mode for the AdonisJS framework
npm install adonisjs-maintenancenpm i adonisjs-maintenance and node ace configure adonisjs-maintenance)
adonisjs-maintenance/CheckForMaintenanceMode as router middleware
adonisjs-maintenance/commands to commands
adonisjs-maintenance/MaintenanceProvider as extra service provider
node ace maintenance
--secret string Secret key to bypass maintenance mode
--message string Custom message for maintenance mode
--allow-ip array Add an ip to the whitelist
`
* The secret can be passed via a GET parameter named 'secret' (localhost:3333/?secret=mysecret) or the header X-Maintenance-Secret
* When maintenance mode is enabled, all requests to the application will have a 503 status (api, web, ...)
* Passing the correct secret adds your IP automaticly to the whitelist
#### Examples
* node ace maintenance --message 'Oh noes! Please come back later.'
* node ace maintenance --secret letmein --message 'Please come back later or enter the secret password to enter ;)'
* node ace maintenance --message 'Maintenance mode is enabled.' --allow-ip 127.0.0.1 --allow-ip 8.8.8.8 --allow-ip 196.128.0.1
$3
This package throws an exception to show a 503 status. Which means you can use status pages which AdonisJS provides.
You can check out this behaviour in the file app/exceptions/handler.ts of your app.
By default it'll show the edge template pages/errors/server_error when a 503 HTTP error occurs:
`ts
protected statusPages: Record = {
//...
'500..599': (error, { view }) => {
return view.render('pages/errors/server_error', { error })
},
}
`
But you can create a new edge template for only the 503 status like so:
`ts
protected statusPages: Record = {
//...
'503': (error, { view }) => {
return view.render('pages/errors/maintenance', { error })
},
'504..599': (error, { view }) => {
return view.render('pages/errors/server_error', { error })
},
}
`
The custom message can be shown in the view like so:
`edge
{{ error.status }} - Maintenance
Maintenance mode activated, please come back later.
{{ error.message }}
``