summaryrefslogtreecommitdiffstats
path: root/GitAutoDeploy.py
diff options
context:
space:
mode:
authorAlexander Nestorov <alexandernst@gmail.com>2014-10-16 09:49:43 +0200
committerAlexander Nestorov <alexandernst@gmail.com>2014-10-16 09:49:43 +0200
commit6502d11238cb4c98d85f74aabe1920da037964b7 (patch)
treeeeec8f6b81412cc89dd12dc159c1009dbb07dfe0 /GitAutoDeploy.py
parentae88a3d418416011845344e9aa852fe05e9bcccf (diff)
parente05d5bf11fec49f2bc01bd6f501be271acae4137 (diff)
downloadGit-Auto-Deploy-6502d11238cb4c98d85f74aabe1920da037964b7.zip
Git-Auto-Deploy-6502d11238cb4c98d85f74aabe1920da037964b7.tar.gz
Git-Auto-Deploy-6502d11238cb4c98d85f74aabe1920da037964b7.tar.bz2
Merge pull request #18 from BOFHers/master
Play nicer with the exit code/status
Diffstat (limited to 'GitAutoDeploy.py')
-rwxr-xr-xGitAutoDeploy.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/GitAutoDeploy.py b/GitAutoDeploy.py
index 4ad013d..8d1f7da 100755
--- a/GitAutoDeploy.py
+++ b/GitAutoDeploy.py
@@ -19,23 +19,28 @@ class GitAutoDeploy(BaseHTTPRequestHandler):
try:
configString = open(myClass.CONFIG_FILEPATH).read()
except:
- sys.exit('Could not load ' + myClass.CONFIG_FILEPATH + ' file')
+ print "Could not load %s file" % myClass.CONFIG_FILEPATH
+ sys.exit(2)
try:
myClass.config = json.loads(configString)
except:
- sys.exit(myClass.CONFIG_FILEPATH + ' file is not valid json')
+ print "%s file is not valid JSON" % myClass.CONFIG_FILEPATH
+ sys.exit(2)
for repository in myClass.config['repositories']:
if(not os.path.isdir(repository['path'])):
- sys.exit('Directory ' + repository['path'] + ' not found')
+ print "Directory %s not found" % repository['path']
+ sys.exit(2)
if(not os.path.isdir(repository['path'] + '/.git')):
- sys.exit('Directory ' + repository['path'] + ' is not a Git repository')
+ print "Directory %s is not a Git repository" % repository['path']
+ sys.exit(2)
return myClass.config
def do_POST(self):
urls = self.parseRequest()
+ self.respond()
Timer(1.0, self.do_process, [urls]).start()
def do_process(self, urls):
@@ -44,7 +49,6 @@ class GitAutoDeploy(BaseHTTPRequestHandler):
for path in paths:
self.pull(path)
self.deploy(path)
- self.respond()
def parseRequest(self):
length = int(self.headers.getheader('content-length'))
@@ -124,8 +128,8 @@ class GitAutoDeployMain:
if(GitAutoDeploy.daemon):
pid = os.fork()
- if(pid != 0):
- sys.exit()
+ if(pid > 0):
+ sys.exit(0)
os.setsid()
self.create_pidfile()