summaryrefslogtreecommitdiffstats
path: root/GitAutoDeploy.py
diff options
context:
space:
mode:
authorchivorotkiv <shmakov@omich.net>2015-05-03 11:26:59 +0600
committerchivorotkiv <shmakov@omich.net>2015-05-03 11:26:59 +0600
commite6930422c69fac5c998b6ce3b223cfff5da4fd22 (patch)
tree2f29711f258cb4ec580ef237f0747488efcc1587 /GitAutoDeploy.py
parent11d7b797624cec8bece0e776211faa1af68de5b4 (diff)
downloadGit-Auto-Deploy-e6930422c69fac5c998b6ce3b223cfff5da4fd22.zip
Git-Auto-Deploy-e6930422c69fac5c998b6ce3b223cfff5da4fd22.tar.gz
Git-Auto-Deploy-e6930422c69fac5c998b6ce3b223cfff5da4fd22.tar.bz2
Make "pull" process more stable: Reduce probability of .git/index.lock problem
Diffstat (limited to 'GitAutoDeploy.py')
-rwxr-xr-xGitAutoDeploy.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/GitAutoDeploy.py b/GitAutoDeploy.py
index 485d84f..487e9b2 100755
--- a/GitAutoDeploy.py
+++ b/GitAutoDeploy.py
@@ -49,8 +49,11 @@ class GitAutoDeploy(BaseHTTPRequestHandler):
for repo in repos:
if self.lock(repo['path']):
try:
- self.pull(repo['path'], repo['branch'])
- self.deploy(repo['path'])
+ n = 4
+ while 0 < n and 0 != self.pull(repo['path'], repo['branch']):
+ --n
+ if 0 < n:
+ self.deploy(repo['path'])
except:
call(['echo "Error during \'pull\' or \'deploy\' operation on path: ' + repo['path'] + '"'], shell=True)
finally:
@@ -127,7 +130,7 @@ class GitAutoDeploy(BaseHTTPRequestHandler):
if(not self.quiet):
print "\nPost push request received"
print 'Updating ' + path
- res = call(['cd "' + path + '" && git fetch origin ; git update-index --refresh &> /dev/null ; git reset --hard origin/' + branch], shell=True)
+ res = call(['sleep 5; cd "' + path + '" && git fetch origin ; git update-index --refresh &> /dev/null ; git reset --hard origin/' + branch], shell=True)
call(['echo "Pull result: ' + str(res) + '"'], shell=True)
return res