>_ IzzyLab

Hands-on task

This task is step 9 of the course “Shipping a release”

Switch prod to the new release with a symlink

medium~5 min

Release 2.4.0 of billing is already laid out on the server next to the running 2.3.7: the directories are in /srv/billing/releases/, and nginx serves the site from the symlink /srv/billing/current. Switch prod to 2.4.0 by repointing the symlink. Don't touch the nginx config, don't stop nginx, and current must stay a symlink. Careful: the candidate 2.4.0-rc1 is lying there too — you don't need it.

What you'll practise:
  • symlinks
  • ln -sfn
  • readlink
  • blue-green deployment
  • zero-downtime release

Topic breakdown

The "one directory per release + a current symlink" layout is a zero-downtime deployment classic: the new version is uploaded to a separate directory ahead of time, and at release time only the pointer the web server looks at changes. A rollback works the same way — the link is pointed back at the previous directory. What matters is that replacing the link is a single operation: ln with the flags for a symbolic link, forced replacement and not dereferencing the old directory target. Deleting the link and creating it again opens a window in which the site returns errors, and cp instead of a link breaks fast rollback.

What's checked

  1. /srv/billing/current is still a symlink
  2. current points to release 2.4.0
  3. the site serves release 2.4.0
  4. nginx is running
  5. the old release is intact for a rollback

What it looks like