During a deploy you show a maintenance page. If the deploy fails, the page stayed up last time. Fix the script.
BeginnerScenarioScenarios: deployments, user management and fleet operations
Answer
Situation read → The removal step was at the end of the happy path, so any failure skipped it.
What I'd do →
maintenance_on() { touch /srv/app/shared/maintenance.flag; }
maintenance_off() { rm -f /srv/app/shared/maintenance.flag; }
maintenance_on
trap maintenance_off EXIT
run_migrations
switch_release
- nginx serves the page when the flag exists:
if (-f /srv/app/shared/maintenance.flag) { return 503; }with anerror_page 503. - The
EXITtrap removes it on success, failure, or Ctrl+C.
Why → Traps make cleanup independent of which line failed.
Interview tip → Mention that a 503 with a Retry-After header is better for clients and SEO than a 200 maintenance page.
More on Scenarios: deployments, user management and fleet operations
Write the core of a deploy script with release directories, an atomic symlink switch and rollback.IntermediateDeploy to 10 servers behind an AWS ALB one at a time, removing each from the target group during its deploy. Outline the script.AdvancedAfter a deploy, the health check fails intermittently. Your script must roll back automatically, but only if the failure persists. How?IntermediateImplement a blue/green switch on a single nginx host with a script.AdvancedOnboard 30 engineers: create accounts and install their SSH keys from their GitHub usernames, idempotently.IntermediateAn engineer leaves the company. Write the offboarding steps for Linux servers.Intermediate