def rollback(): """Swaps the deployed version of the app to the previous version. Requires the env keys: path - root deploy target for this app releases_root - subdirectory that stores the releases current_release_symlink - name of the symlink pointing to the currently deployed version Optional: crontab - relative path from the project root to a crontab to install deploy_user - user that should run the crontab """ require('path') require('releases_root') require('current_release_symlink') require('crontab') require('deploy_user') with cd(os.path.join(env.path, env.releases_root)): previous_link = deploy.release.alternative_release_path() conditional_rm(env.current_release_symlink) run('ln -fs %s %s' % (previous_link, env.current_release_symlink)) deploy.cron.conditional_install_crontab(utils.absolute_release_path(), env.crontab, env.deploy_user) restart_webserver()
def _symlink_current_release(next_release_path): with cd(os.path.join(env.path, env.releases_root)): conditional_rm(env.current_release_symlink) run('ln -fs %s %s' % (next_release_path, env.current_release_symlink))