Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to pass through stdout? #50

Open
JonDum opened this issue Mar 2, 2019 · 5 comments
Open

How to pass through stdout? #50

JonDum opened this issue Mar 2, 2019 · 5 comments

Comments

@JonDum
Copy link

JonDum commented Mar 2, 2019

We have a bunch of images that need to be pushed to a registry so often, so we do them all in one big script. Problem is Gitlab's container registry constantly fails all the time so loop is a perfect fit for this.
Trying something like:

loop -s --summary -- scripts/push-images.sh (tried with -i as well)

But the problem is that there is zero output.

Whereas normally our scripts/push-images.sh outputs something like:

Pushing registry.gitlab.com/thing:prod
The push refers to repository [registry.gitlab.com/thing]
8850e5e866c3: Preparing
6d1eb370deee: Preparing
e6a9e93f2e3d: Preparing
f721b22510f1: Preparing
371e12a4bca7: Preparing
c97278a08a46: Preparing
7bff100f35cb: Preparing
c97278a08a46: Waiting

And updates as the scripts progress through each image.

Is there anyway to keep that stdout and print it to term live as loop receives it from the subprocess?

@JonDum
Copy link
Author

JonDum commented Mar 2, 2019

Might be helpful of what scripts/push-images.sh is in case this is actually not the expected behavior:

#!/bin/bash

set -e

blue=$(tput setaf 4)
magenta=$(tput setaf 5)
yellow=$(tput setaf 3)
normal=$(tput sgr0)

function tagnbag() {
	tag="$1"
	gitlabTag="registry.gitlab.com/companyname/$1"
	docker tag $tag $gitlabTag
	printf "\n${blue}Pushing $gitlabTag ${normal}\n"
	docker push $gitlabTag
}

tagnbag companyname/image1:prod
tagnbag companyname/image2:prod
tagnbag companyname/image3:prod
tagnbag companyname/image4:prod
tagnbag companyname/image5:prod

# so on and so forth

@Miserlou
Copy link
Owner

Miserlou commented Mar 2, 2019

😍 tagnbag 😍

This is an excellent use case that we should absolutely support.

I'm guessing this is possibly related to #7

Can you describe what does happen? Does it just exit with no output, or hang indefinitely? I'd like to be able to have a smallest possible reproduction of this.

@Miserlou
Copy link
Owner

Miserlou commented Mar 2, 2019

@art-of-dom any ideas about this one?

@art-of-dom
Copy link
Collaborator

After a little research it looks like we can do something similar to this: https://rust-lang-nursery.github.io/rust-cookbook/os/external.html#continuously-process-child-process-outputs.

It may be even simpler than this since we don't need to process the output, just display it.

@JonDum
Copy link
Author

JonDum commented Mar 3, 2019

Can you describe what does happen? Does it just exit with no output, or hang indefinitely? I'd like to be able to have a smallest possible reproduction of this.

I'm pretty sure loop is running it, but outputs nothing while it is running. If the command fails, it then outputs the entirety of the stdout of the command up until it failed and goes silent again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants