>_ IzzyLab

Hands-on task

This task is step 18 of the course “nginx basics”

Blue-green release switch

medium~5 min

nginx serves the app through the symlink /opt/current, which points at release v1 in /opt/releases/. Release v2 is already uploaded. Switch prod to v2 by moving the symlink — without touching the nginx config and without restarting it: nginx keeps running, only the link changes.

What you'll practise:
  • symlinks
  • ln
  • readlink
  • blue-green deployment
  • atomic switch

Topic breakdown

Blue-green deployment via a symlink is a way to switch releases with no downtime: prod looks not at a specific version folder but at a symbolic-link pointer, which gets re-pointed at a new directory. The point is atomicity: replacing the link must happen in one motion, with no gap when the link is missing. A plain ln on an existing link either trips up or creates nesting, so you need the flags to recreate a symbolic link, force-overwrite, and forbid entering inside the old target; the server config isn't touched at all in the process.

What's checked

  1. /opt/current points at v2
  2. the site serves release v2
  3. nginx keeps running without a restart
  4. the nginx config is unchanged

What it looks like