1
0
mirror of https://github.com/IEEE-SB-Passau/pelican-deployment-system.git synced 2017-09-06 16:35:38 +02:00

more logging things

This commit is contained in:
2016-06-13 00:58:13 +02:00
parent 34983adcd1
commit d249e31ea5
4 changed files with 21 additions and 3 deletions

View File

@@ -1,4 +1,5 @@
import os import os
import logging
if __name__ == "__main__": if __name__ == "__main__":
raise SystemExit("Not meant to be run directly!") raise SystemExit("Not meant to be run directly!")
@@ -8,6 +9,9 @@ def _rsync_cmd(dest):
"'{output}/' '{dest}'") "'{output}/' '{dest}'")
return cmd.format(dest=dest, output="{output}") return cmd.format(dest=dest, output="{output}")
# configure the logger
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(message)s')
# make sure git does not block giving pw prompts, git 2.3+ only # make sure git does not block giving pw prompts, git 2.3+ only
os.environ["GIT_TERMINAL_PROMPT"] = "0" os.environ["GIT_TERMINAL_PROMPT"] = "0"

View File

@@ -1,11 +1,10 @@
#! /usr/bin/env python3 #! /usr/bin/env python3
import deploy_config
from pelican_deploy import DeploymentRunner from pelican_deploy import DeploymentRunner
import pelican_deploy.webhookbottle import pelican_deploy.webhookbottle
import deploy_config
import logging import logging
logging.basicConfig(level=logging.DEBUG)
runners = {name: DeploymentRunner(name, conf) runners = {name: DeploymentRunner(name, conf)
for name, conf in deploy_config.RUNNERS.items()} for name, conf in deploy_config.RUNNERS.items()}

View File

@@ -3,6 +3,7 @@ from collections import namedtuple
from pelican_deploy.gittool import Repo, log_git_result from pelican_deploy.gittool import Repo, log_git_result
from functools import partial from functools import partial
from subprocess import Popen, PIPE from subprocess import Popen, PIPE
from pelican_deploy.util import exception_logged
from concurrent.futures import ThreadPoolExecutor from concurrent.futures import ThreadPoolExecutor
from threading import RLock from threading import RLock
import sys import sys
@@ -49,8 +50,13 @@ class DeploymentRunner:
self._build_proc = None self._build_proc = None
self._abort = False self._abort = False
self._build_lock = RLock() self._build_lock = RLock()
self._repo_update_lock = RLock()
def update_build_repository(self): def update_build_repository(self):
with self._repo_update_lock:
self._update_build_repository()
def _update_build_repository(self):
repo = Repo(str(self.build_repo_path)) repo = Repo(str(self.build_repo_path))
if not repo.is_repo(): if not repo.is_repo():
if self.build_repo_path.is_dir() and \ if self.build_repo_path.is_dir() and \
@@ -110,7 +116,8 @@ class DeploymentRunner:
if fut.done(): if fut.done():
self._futures.remove(fut) self._futures.remove(fut)
self._futures.add(self._executor.submit(self.build_blocking)) build_func = exception_logged(self.build_blocking, log.error)
self._futures.add(self._executor.submit(build_func))
def try_abort_build(self): def try_abort_build(self):
proc = self._build_proc proc = self._build_proc

8
pelican_deploy/util.py Normal file
View File

@@ -0,0 +1,8 @@
def exception_logged(func, log):
def wrapped(*args, **kwargs):
try:
func(*args, **kwargs)
except:
log("Caught Exception!", exc_info=True)
raise # reraise