2

During the running of my OpsWorks deploy recipes, there is a period of time when the app needs to be inaccessible by the public. Is there a recommended way to achieve this?

It's a Magento site, and I created two recipes. One to create maintenance.flag and one to delete it again. This tells Magento to serve a holding page with an HTTP 503 response code.

Two problems with this:

  • Since I'm running the recipes at the start and end of the custom recipes, the maintenance mode is only in place for a few seconds - not long enough.
  • Serving the 503 from the app servers is probably the wrong way to go. It'd be better to switch to maintenance mode on the load balancer, probably? Otherwise the load balancer (and OpsWorks?) will see the app instances as offline.

Is there a way to run my maintenance mode recipe before the code is pulled from git, or immediately after? Or some way to use an undeploy recipe? Or something better?

1 Answers1

1

Opsworks has an option to manually execute a recipe through deployments: http://docs.aws.amazon.com/opsworks/latest/userguide/workingcookbook-manual.html

I'd recommend manually running your recipe here to put the site into maintenance mode and then executing your deployment, which should take down maintenance mode as its final step.

While this is a manual operation, if you have a continuous integration/deployment environment, it's worth noting that you can do the same thing via the AWS CLI: http://docs.aws.amazon.com/cli/latest/reference/opsworks/create-deployment.html

The general idea is you would script a deployment on build completion, run your recipe which puts it into maintenance mode, then run a real deployment.

Hope this helps!

EDIT

You can also utilize chef deployment hooks to execute a maintenance mode setup and teardown. See: http://docs.aws.amazon.com/opsworks/latest/userguide/workingcookbook-extend-hooks.html

Choose the respective hooks you want to tie into, and create a deploy folder at the root of your application.

buzzedword
  • 111
  • 4