3 ms·
Push and reset are not atomic, so you will risk race conditions this way: While Git is updating the local directory, a user may be visiting the site and will be
by lobster_johnson 15y ago
Push and reset are not atomic, so you will risk race conditions this way: While Git is updating the local directory, a user may be visiting the site and will be loading files that are in different version states.
The only way to atomically deploy an application is to clone into a new directory and then write a symlink to point to the new directory. You can maintain a local Git cache that contains the newest tree and clone from that; Git uses hard links, so the clone will be fast. So something like:
cd $cache && git fetch origin && git reset --hard $version && \
git clone $cache $temp && ln -sf $temp $current
Of course, apps can be designed to avoid the race condition, by caching the application's files. Rails and Sinatra will do this (but only for Ruby files), for example.
Edit Reply