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

This commit is contained in:
2016-06-11 23:30:27 +02:00
parent 0ea23ffd60
commit 3d17c1ba7a

View File

@@ -1,7 +1,7 @@
from pathlib import Path from pathlib import Path
from collections import namedtuple from collections import namedtuple
from git import Repo, InvalidGitRepositoryError, NoSuchPathError from git import Repo, InvalidGitRepositoryError, NoSuchPathError
from subprocess import Popen from subprocess import Popen, PIPE
from concurrent.futures import ThreadPoolExecutor from concurrent.futures import ThreadPoolExecutor
from threading import RLock from threading import RLock
import sys import sys
@@ -62,6 +62,9 @@ class DeploymentRunner:
branch=self.git_branch) branch=self.git_branch)
if build_repo.remotes.origin.url != self.clone_url: if build_repo.remotes.origin.url != self.clone_url:
log.info("%s build_repo: URL of git origin changed (`%s` --> `%s`),\
adjusting...", self.name, build_repo.remotes.origin.url,
self.clone_url)
cw = build_repo.remotes.origin.config_writer cw = build_repo.remotes.origin.config_writer
cw.set("url", self.clone_url) cw.set("url", self.clone_url)
cw.release() cw.release()
@@ -73,12 +76,14 @@ class DeploymentRunner:
# they should stay around in .git, so reinit should be fast # they should stay around in .git, so reinit should be fast
build_repo.git.submodule("deinit", ".") build_repo.git.submodule("deinit", ".")
log.info("%s build_repo: pulling changes from origin", self.name)
build_repo.remotes.origin.pull( build_repo.remotes.origin.pull(
force=True, force=True,
no_edit=True, no_edit=True,
refspec="+{b}:{b}".format(b=self.git_branch), refspec="+{b}:{b}".format(b=self.git_branch),
recurse_submodules="yes") recurse_submodules="yes")
log.info("%s build_repo: resetting the working tree", self.name)
# forcefully reset the working tree # forcefully reset the working tree
build_repo.head.reset(index=True, working_tree=True) build_repo.head.reset(index=True, working_tree=True)
try: try:
@@ -118,13 +123,27 @@ class DeploymentRunner:
# start the build if we should not abort # start the build if we should not abort
if not self._abort: if not self._abort:
args = shlex.split(self.build_command) args = shlex.split(self.build_command)
self._build_proc = Popen(args, log.info("%s: Starting build_command `%s`", self.name, args)
self._build_proc = Popen(args, stdout=PIPE, stderr=PIPE,
cwd=str(self.build_repo_path), cwd=str(self.build_repo_path),
env=self._build_proc_env) env=self._build_proc_env)
atexit.register(self._build_proc.kill) atexit.register(self._build_proc.kill)
outs, errs = self._build_proc.communicate()
status = self._build_proc.wait() status = self._build_proc.wait()
atexit.unregister(self._build_proc.kill) atexit.unregister(self._build_proc.kill)
if status < 0:
log.info("%s: killed build_command", self.name)
else:
log.info('%s build_command stdout: %s\n', self.name,
outs.decode(encoding=sys.getdefaultencoding(),
errors='replace'))
log.info('%s build_command stderr: %s\n', self.name,
errs.decode(encoding=sys.getdefaultencoding(),
errors='replace'))
log.info("%s: finished build_command with status %s!",
self.name, status)
if status == 0: if status == 0:
# TODO: postproc... # TODO: postproc...
pass pass