summaryrefslogtreecommitdiffstats
path: root/src/endpoint/configured.rs
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2020-11-06 15:59:21 +0100
committerMatthias Beyer <mail@beyermatthias.de>2020-11-07 14:53:04 +0100
commit0d02347c8d1ea612c112430985723c57c105facd (patch)
tree725dc0355d24b56632eca4f52305c7fd0e1cd1dd /src/endpoint/configured.rs
parent6f37a912c34d2eb7f3ed72475ef469a3d2e37c9c (diff)
Encode script execution in container command
So the container starts building right away and we only need to fetch the log later. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src/endpoint/configured.rs')
-rw-r--r--src/endpoint/configured.rs13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/endpoint/configured.rs b/src/endpoint/configured.rs
index f41a45d..d3dc2a3 100644
--- a/src/endpoint/configured.rs
+++ b/src/endpoint/configured.rs
@@ -180,6 +180,7 @@ impl Endpoint {
let builder_opts = shiplift::ContainerOptions::builder(job.image().as_ref())
.env(envs.iter().map(AsRef::as_ref).collect())
+ .cmd(vec!["/bin/bash", "/script"])
.build();
let create_info = self.docker
@@ -199,9 +200,6 @@ impl Endpoint {
let script = job.script().as_ref().as_bytes();
let script_path = PathBuf::from("/script");
- let exec_opts = ExecContainerOptions::builder()
- .cmd(vec!["/script"])
- .build();
let container = self.docker.containers().get(&container_id);
container
@@ -210,7 +208,14 @@ impl Endpoint {
.then(|_| container.start())
.map(|r| r.with_context(|| anyhow!("Starting the container {} on '{}'", container_id, self.name)))
.then(|_| async {
- let stream = container.exec(&exec_opts);
+ use shiplift::builder::LogsOptions;
+ let log_opts = LogsOptions::builder()
+ .stdout(true)
+ .stderr(true)
+ .timestamps(false)
+ .build();
+
+ let stream = container.logs(&log_opts);
buffer_stream_to_line_stream(stream)
.map(|line| {
trace!("['{}':{}] Found log line: {:?}", self.name, container_id, line);