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