kopia lustrzana https://github.com/jupyterhub/repo2docker
Extreme measures
rodzic
cb4621f254
commit
6e372b5bc9
|
@ -605,12 +605,24 @@ class Repo2Docker(Application):
|
||||||
try:
|
try:
|
||||||
for line in container.logs(stream=True):
|
for line in container.logs(stream=True):
|
||||||
self.log.info(line.decode("utf-8"), extra=dict(phase="running"))
|
self.log.info(line.decode("utf-8"), extra=dict(phase="running"))
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
container.reload()
|
container.reload()
|
||||||
if container.status == "running":
|
if container.status == "running":
|
||||||
self.log.info("Stopping container...\n", extra=dict(phase="running"))
|
self.log.info("Stopping container...\n", extra=dict(phase="running"))
|
||||||
container.kill()
|
container.kill()
|
||||||
exit_code = container.attrs["State"]["ExitCode"]
|
exit_code = container.attrs["State"]["ExitCode"]
|
||||||
|
|
||||||
|
container.wait()
|
||||||
|
|
||||||
|
self.log.info(
|
||||||
|
"Container finished running.\n".upper(), extra=dict(phase="running")
|
||||||
|
)
|
||||||
|
# are there more logs? Let's send them back too
|
||||||
|
late_logs = container.logs().decode("utf-8")
|
||||||
|
for line in late_logs.split("\n"):
|
||||||
|
self.log.info(line + "\n", extra=dict(phase="running"))
|
||||||
|
|
||||||
container.remove()
|
container.remove()
|
||||||
if exit_code:
|
if exit_code:
|
||||||
sys.exit(exit_code)
|
sys.exit(exit_code)
|
||||||
|
|
|
@ -15,10 +15,10 @@ if [[ ! -z "${R2D_ENTRYPOINT:-}" ]]; then
|
||||||
if [[ ! -x "$R2D_ENTRYPOINT" ]]; then
|
if [[ ! -x "$R2D_ENTRYPOINT" ]]; then
|
||||||
chmod u+x "$R2D_ENTRYPOINT"
|
chmod u+x "$R2D_ENTRYPOINT"
|
||||||
fi
|
fi
|
||||||
exec "$R2D_ENTRYPOINT" "$@" >&"$log_fd"
|
exec "$R2D_ENTRYPOINT" "$@" 2>&1 >&"$log_fd"
|
||||||
else
|
else
|
||||||
exec "$@" >&"$log_fd"
|
exec "$@" 2>&1 >&"$log_fd"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Close the logging output again
|
# Close the logging output again
|
||||||
#exec {log_fd}>&-
|
exec {log_fd}>&-
|
||||||
|
|
|
@ -42,13 +42,15 @@ def test_env():
|
||||||
# value
|
# value
|
||||||
"--env",
|
"--env",
|
||||||
"SPAM_2=",
|
"SPAM_2=",
|
||||||
"--",
|
# "--",
|
||||||
tmpdir,
|
tmpdir,
|
||||||
"/bin/bash",
|
"/bin/bash",
|
||||||
"-c",
|
"-c",
|
||||||
# Docker exports all passed env variables, so we can
|
# Docker exports all passed env variables, so we can
|
||||||
# just look at exported variables.
|
# just look at exported variables.
|
||||||
"export",
|
"export; sleep 1",
|
||||||
|
# "export; echo TIMDONE",
|
||||||
|
# "export",
|
||||||
],
|
],
|
||||||
universal_newlines=True,
|
universal_newlines=True,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
|
@ -61,6 +63,9 @@ def test_env():
|
||||||
# stdout should be empty
|
# stdout should be empty
|
||||||
assert not result.stdout
|
assert not result.stdout
|
||||||
|
|
||||||
|
print(result.stderr.split("\n"))
|
||||||
|
# assert False
|
||||||
|
|
||||||
# stderr should contain lines of output
|
# stderr should contain lines of output
|
||||||
declares = [x for x in result.stderr.split("\n") if x.startswith("declare")]
|
declares = [x for x in result.stderr.split("\n") if x.startswith("declare")]
|
||||||
assert 'declare -x FOO="{}"'.format(ts) in declares
|
assert 'declare -x FOO="{}"'.format(ts) in declares
|
||||||
|
|
Ładowanie…
Reference in New Issue