- sh.call("git", "pull", temp_wc_dir, "master")
- version_obj = distutils.version.LooseVersion(version.partition('-')[2])
- try:
- # run update script
- d.application.upgrade(version_obj, options)
- d.verifyWeb()
- except app.UpgradeFailure:
- logging.warning("Upgrade failed: rolling back")
- perform_restore(d, backup)
- raise
- except deploy.WebVerificationError:
- logging.warning("Web verification failed: rolling back")
- perform_restore(d, backup)
- raise app.UpgradeFailure("Upgrade caused website to become inaccessible; site was rolled back")
+ with util.LockDirectory(".scripts-upgrade-lock"):
+ # git merge (which performs a fast forward)
+ sh.call("git", "pull", "-q", temp_wc_dir, "master")
+ # after the pull is successful, the directory now
+ # has the objects for this commit, so we can safely
+ # nuke the shm directory. We refrain from nuking the
+ # tmp directory in case we messed up the merge resolution
+ # and want to be able to use it again.
+ if use_shm:
+ shutil.rmtree(temp_dir)
+ version_obj = distutils.version.LooseVersion(version.partition('-')[2])
+ try:
+ # run update script
+ d.upgrade(version_obj, options)
+ d.verifyWeb()
+ except app.UpgradeFailure:
+ logging.warning("Upgrade failed: rolling back")
+ perform_restore(d, backup)
+ raise
+ except deploy.WebVerificationError as e:
+ logging.warning("Web verification failed: rolling back")
+ logging.info("Web page that was output was:\n\n%s" % e.contents)
+ perform_restore(d, backup)
+ raise app.UpgradeVerificationFailure("Upgrade caused website to become inaccessible; site was rolled back")