News for hackers. Stuff that matters.
Re:Race-condition-free deployment with the "symlink replacem... by kelnos on Monday October 22, 2012 @04:47AM (#4682303)
But what if you don't have a handle to a file? Say you have index.php, which includes stuff.php. Order of operations:

  1. Server opens (old) index.php and begins executing
  2. Symlink swap
  3. Interpreter gets to the line that includes stuff.php, and then opens the *new* file
Re:Race-condition-free deployment with the "symlink replacem... by regularfry on Monday October 22, 2012 @05:48AM (#4682406)
That's precisely why the classical PHP model is kinda stuffed under this situation.

If you want to stick with the traditional disc-read-per-request model, I'd be interested to see if something like a blue/green code deployment could work. You'd have two separate html roots - say, with /var/www/blue being current. You deploy your new code to /var/www/green, update httpd.conf to point there, then SIGHUP apache. The next deployment would switch back from /var/www/green to /var/www/blue. That way every request sees a consistent deployment from start to end.

Re:Race-condition-free deployment with the "symlink replacem... by IsTom on Monday October 22, 2012 @10:04AM (#4683153)
If you use relative paths 3 will include old file. I'm not sure if that's a problem in PHP, but everything I used handled that fine.