Skip to content

Commit

Permalink
Add support for stage logs option (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushr2 authored Aug 31, 2019
1 parent b1daacd commit 0863d31
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ stages = [{
"privileged": True,
# the number of seconds until the container is killed (optional, defaults to 30)
"timeout": 30,
# enable saving the logs from this stage
"logs": False,
# container environment additions/overrides (optional, defaults to none)
"env": {
"VAR1": "1"
Expand Down
9 changes: 5 additions & 4 deletions chainlink/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,12 @@ async def _run_stage(self, stage, mount, environ):
result = {
"data": self.client.api.inspect_container(container.id)["State"],
"killed": killed,
"logs": {
"stdout": container.logs(stderr=False, timestamps=True),
"stderr": container.logs(stdout=False, timestamps=True),
},
"logs": {"stdout": None, "stderr": None},
}
if stage.get("logs", True):
result["logs"]["stdout"] = container.logs(stderr=False, timestamps=True)
result["logs"]["stderr"] = container.logs(stdout=False, timestamps=True)

result["success"] = (not killed) and (result["data"]["ExitCode"] == 0)
container.remove()

Expand Down

0 comments on commit 0863d31

Please sign in to comment.