How to configure maintenance windows
An active maintenance window prevents any notifications to be sent. This can be handy to turn on when having planned downtime, or while deploying your application.
For example when you integrated Application Health Monitoring you can let Oh Dear keep an eye on Horizon (Laravel Redis queue manager). The moment Horizon goes down, Oh Dear can detect this and can notify you.
When deploying it’s very likely you will be restarting Horizon at some point in the script. When restarting Horizon it will first shutdown and then start again. This action is near instant however, Oh Dear very often can still detect this small window of downtime of Horizon and results in a notification being sent.
How to initiate and end a maintenance window
The easiest and most likely way of implementing it for Laravel apps is using the CLI package and extending your current deployment script.
All you have to do is add this command at the start of your script
php artisan maintenance period:start. At the end of the script you can end the initiated maintenance widow with
php artisan maintenance period:stop.
Any other framework
For any other framework you can use the same approach but you will need to use the Oh Dear API directly. First set a variable containing the API token like this:
$ OHDEAR_TOKEN="your API token
$ curl -X POST https://ohdear.app/api/sites/1/start-maintenance \ -H "Authorization: Bearer $OHDEAR_TOKEN" \ -H 'Accept: application/json' \ -H 'Content-Type: application/json'
Then at the end of your script you can end the maintenance window with:
$ curl -X POST https://ohdear.app/api/sites/1/stop-maintenance \ -H "Authorization: Bearer $OHDEAR_TOKEN" \ -H 'Accept: application/json' \ -H 'Content-Type: application/json'
Good to know
All maintenance windows default to a 60 minute period. After 60 minutes the maintenance period will automatically be ended. You can read more about this feature in our blog post and other documentation articles Maintenance windows via the API and Maintenance windows via the SDK