Docs/Features

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.

Screenshot maintenance Periods

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

You can initiate a maintenance window via the API, the SDK or with the Oh Dear CLI package. Depending on the framework you have several options to implement the maintenance windows feature.

Laravel

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 ohdear-cli maintenance period:start [site-id] [seconds]. Where site-id is the id of your site within Oh Dear. You can find the id of your sites with ohdear-cli sites:list. The number of seconds is the maximum amount of time the maintenance window should be active. You could set this to any sensible amount, but make sure its longer than your deployment takes. At the end of the script you can end the maintenance window with ohdear-cli maintenance period:stop [site-id].

An alternative way to work with maintenance windows without any package is via the API by using curl. Which is explained in the next section.

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

Was this page helpful?

Feel free to reach out via [email protected] or on Twitter via @OhDearApp if you have any other questions. We'd love to help!