whoami
Lucas Jenß
cat /etc/motd
The Coding Journal ツ — Notes taken on an epic coding journey. Technical solutions, debugging notes, and practical guides from the trenches of software development.
ls -la ~/languages/
- drwxr-xr-x
- ▶ PHP
- ▶ Ruby
- ▶ Scala
- ▶ C#
- ▶ JavaScript
- ▶ Objective-C
- ▶ Shell Scripting
ls -la ~/toolchain/
- drwxr-xr-x
- ▶ Typo3
- ▶ Akka
- ▶ Capistrano
- ▶ Git
- ▶ MAMP
- ▶ Adobe Illustrator
- ▶ NSTrackingArea (Cocoa)
uname -a
- drwxr-xr-x
- ▶ Mac OS X
- ▶ Unix
Rolling Back a Failed Capistrano Deployment With Zero Downtime
Capistrano makes deployment repeatable, but a repeatable deploy is not automatically reversible. When a release fails after code has moved into production, the safest response is usually to restore the last known-good release while keeping the application reachable. With the right release layout, that rollback can happen in seconds rather than becoming a prolonged incident.
Zero downtime means no meaningful gap in successful request handling during the switch. It does not mean every long-running request, background job or cached session instantly belongs to the previous version. Those components need explicit handling: code can point backwards immediately while workers are recycled and data compatibility is checked.
The central pattern is immutable release directories, shared mutable state and an atomic current symlink. Capistrano already fits that model: each deployment receives its own release path, while configuration, uploads and similar resources stay outside the release. Rollback then changes one pointer instead of copying old files over a live application.
Treat rollback as a rehearsed operation, not an emergency button discovered during an outage. Record the target release, test it in staging, define abort thresholds and include the database, queues and caches in the rehearsal. That discipline is especially valuable for teams serving Sydney, Melbourne and regional Australia from Australian or nearby cloud regions.
Understand the rollback path
Capistrano normally keeps each checkout under releases/, links shared resources under shared/, and exposes the active release through current. A rollback task can point current at the preceding release, although task names and cleanup behaviour vary between Capistrano versions. Inspect your project with cap -T before relying on a command such as cap production deploy:rollback.
The safest comparison is between release switching, file replacement, blue-green releases and rolling hosts:
| Strategy | Switchover | Operational benefit | Main risk |
|---|---|---|---|
Atomic current symlink |
Atomic rename | Fastest rollback; active requests keep old files | Old workers or incompatible schema remain |
| Copy over live files | File-by-file replacement | Works without a release layout | Mixed versions and a visible partial state |
| Blue-green release | Traffic moves after health checks | Full validation before cutover | Extra capacity and routing complexity |
| Rolling host replacement | Hosts change in batches | Limits blast radius | More orchestration and session handling |
Atomic symlink switching is usually the best default for a Capistrano release layout, provided the old and new versions can share the same data. The discipline resembles the checkpoints in this app lifecycle guide: publishing code is one event, while activation, verification and recovery need separate controls. In Capistrano, a rollback is a controlled transition to a known release, not merely an ln command.
Prepare releases for a clean reversal
Keep shared state out of release directories. A rolled-back release still needs .env files, uploaded media, certificates and generated assets. Store those under shared/ and expose them with linked_files or linked_dirs; do not assume the failed release contains them. Retain at least one previous release until its observation window closes, then let Capistrano’s cleanup remove older directories.
Local rehearsals still need to match the server. Shell flags, symlink semantics and process managers can differ between a developer Mac and a Linux host; my macOS deployment notes cover that gap. Run the rollback command against staging and inspect the resulting current target on every release role, rather than assuming one machine proves the whole fleet.
Code and data must move in a backwards-compatible order. Prefer expand-and-contract migrations: add a nullable column or new table in one release, let both versions operate against it, then remove the old structure only after the previous release is retired. A rollback should not reverse a destructive migration automatically. Similarly, retain assets required by the older release or version cache keys by release.
Execute the rollback and prove recovery
Before switching anything, capture the failing release ID, current symlink target, recent deploy output, application errors and the intended previous release. Confirm whether the deployment failed before or after publication: if current still points to the good release, a blind rollback may select a release that is too old. Rehearse the exact task, including hooks, in a staging environment with production-like shared directories.
During the switch, ensure the symlink update is atomic. On typical GNU/Linux hosts, create a uniquely named temporary symlink beside current and rename it over the old pointer with mv -Tf; both paths must share a filesystem. Avoid rm current && ln -s ..., which creates a gap between unlink and creation. A custom Capistrano task can implement this behaviour. On multiple app hosts, change all release roles or drain nodes in controlled batches, and never leave mixed versions running unless they are compatible.
Pointer switching alone does not reset PHP-FPM opcache, a preloaded application server or long-running workers. Reload or recycle those processes gracefully so in-flight requests finish and new requests use the restored release. Verify recovery with an external health check and a synthetic transaction, then watch error rate, latency and queue depth. Keep the failed release for diagnosis, but do not route traffic to it.
Rollback readiness checklist
A clean rollback also accounts for work that escaped the request: queued jobs, outbound webhooks, cache writes and database changes. A failed release may have enqueued messages before its health check failed, so restoring code does not automatically make those messages safe. Version the payload, make handlers idempotent and decide explicitly whether to discard, retry or quarantine incompatible jobs.
Security settings deserve the same care. If an internal endpoint uses an IP allowlist, keep the rule in shared configuration and verify it with PHP IP validation before recovery depends on it. A rollback should restore trusted configuration without importing stale secrets or permissions from the failed release.
- Keep at least one healthy previous release and a snapshot of its shared configuration until the release has passed its observation period.
- Use expand-and-contract database changes; leave destructive cleanup out of deploy and rollback hooks.
- Include an application or schema version in queued jobs, and make retryable handlers safe to run more than once.
- Namespace release-specific caches and preserve static assets needed by the version being restored.
- Define failure thresholds, the rollback command, an owner and a target recovery time before each production release.
- Rehearse the switch in staging, then verify traffic, workers, queues and data through independent health checks.
Run releases around Australian conditions
Australian teams often place primary workloads in Sydney or Melbourne through AWS EC2 ap-southeast-2, Azure Australia East or local hosting providers, with Singapore or Tokyo capacity used for overflow. That geography makes a quick symlink switch useful, but region-specific checks matter. A rollback tested only from a Brisbane office can hide poor NBN paths or variable 4G and 5G connections, including those supplied by Telstra or Optus.
Record timestamps in UTC and display Australian Eastern Standard Time, which is UTC+10, while remembering that daylight saving moves the local clock to AEDT, UTC+11. Schedule releases around Australian business hours, state public holidays and quiet weekend windows rather than copying a schedule from another market. Keep health-check payloads and deploy logs free of personal information, consistent with Australian Privacy Act expectations and local customer contracts.
Run a rollback drill in staging during your next maintenance window: create a staging release, force its health check to fail, run the documented rollback and record how long traffic, workers, queues and data checks take to recover. Capture the exact commands and any missing dependency in the runbook. Repeat the exercise whenever Capistrano, the runtime, database schema or hosting topology changes.
cat ~/interests.json
| Key | Value |
|---|---|
| editor | Terminal-first workflow |
| os | Mac OS X / Unix |
| vcs | Git, distributed version control |
| deploy | Capistrano, cron automation |
| graphics | SVG, Adobe Illustrator troubleshooting |
| networking | IP validation, SSH, VPN |
git log --oneline --reverse
Solving SVG import issues in Adobe Illustrator CS6 and CC
When importing an SVG into Illustrator, the operation fails with an unknown error [CANT]. A workaround for this Adobe-side bug.
Solving NDK build issues on OS X
Troubleshooting native development kit compilation problems on Mac OS X.
Programmatically adding PHP generated TypoScript to the backend configuration
Integrating dynamically generated TypoScript into Typo3 backend setups using PHP.
ArgumentError: Could not parse PKey: no start line
Debugging an SSH key parsing error encountered during deployment.
Validating IP-Addresses in PHP
Using PHP filter functions with flags like FILTER_FLAG_IPV4 and FILTER_FLAG_IPV6, and understanding how filter_var handles reserved IP addresses.
Cocoa: Using NSTrackingArea
A short tutorial on using Cocoa's NSTrackingArea to capture mouseEntered and mouseExited events.
cat ~/contact.txt