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

Problems executing shell scripts #40

Closed
robertoandrade opened this issue Aug 29, 2015 · 9 comments
Closed

Problems executing shell scripts #40

robertoandrade opened this issue Aug 29, 2015 · 9 comments
Assignees
Labels

Comments

@robertoandrade
Copy link

I'm having issues trying to execute shell scripts as a consequence of the build, it seems not to be able to find the scripts either if I execute them directly or via a shell:

script:
  - ./build.sh
  - ./deploy.sh
ignore:
  - .git
  - .snag.yml
verbose: true

or

script:
  - bash -c build.sh
  - bash -c deploy.sh
ignore:
  - .git
  - .snag.yml
verbose: true

don't work.

When I try by appending ./ as a prefix to the script name it seems to work but no output of the script is shown and I end up getting an error after a bit:

|In Progress| bash -c ./build.sh|In Progress| bash -c ./build.sh
|Failed     | bash -c ./build.sh
open /dev/null: too many open files
@robertoandrade
Copy link
Author

Ok, I was able to workaround it like I mentioned in the description by appending ./ to the path of the script and had to add a folder to the ignore list that my script was modifying contents for. I guess this goes back to the known issue described in the README?

Additionally, is there a way to see the output of the shell script as it builds it instead of only after it's done executing? i.e.: one of my scripts executes: docker logs -f container

@zabawaba99
Copy link
Collaborator

Ok, I was able to workaround it like I mentioned in the description by appending ./ to the path of the script and had to add a folder to the ignore list that my script was modifying contents for

This sounds like the endless loop caveat listed on the readme. If your script is modifying something in the path that snag is watching then it will trigger a rebuild and loop.

When I try by appending ./ as a prefix to the script name it seems to work but no output of the script is shown and I end up getting an error after a bit:

|In Progress| bash -c ./build.sh|In Progress| bash -c ./build.sh
|Failed     | bash -c ./build.sh
open /dev/null: too many open files

I've reproduced this a few times on OSX when using snag on a directly that has a large number of files. If you look at the known issues there's a link to bump up the number of files that your shell can have open to support projects with a lot of files.


Unfortunately, there is no way to see the progress of a command. We started off with an implementation that had streaming support but it ended up with some odd behavior at the time and decided to leave it on the back burner. @Tonkpils any thoughts on have a way to streaming command output?

@zabawaba99
Copy link
Collaborator

Do you get the same error if you try and run a simple shell script like:

#!/bin/bash -ex

echo "Hello World

?

@Tonkpils
Copy link
Owner

Stream support would actually be very useful, however I do remember the issues we ran into when attempting to re-start the build. The process itself would keep writing to stdout. It might e good to re-visit this and attempt to find a fix for it. As for the shell script, I'll look into what might be the issue unless you get to it first @zabawaba99

@zabawaba99
Copy link
Collaborator

Let's move the discussion of stream support over to #41.

As far as the shell scripting, have at it. I won't be able to get to it for a while.

@zabawaba99
Copy link
Collaborator

@robertoandrade So what this issues related more to not being able to see the output of the script while it's running?

I ran the binary against this project and got a successful build.
screen shot 2015-09-09 at 10 05 48 am

@robertoandrade
Copy link
Author

It looks like it only works if you have the shebangs shenanigans on the shell script, otherwise it throws out an error:

|Failed     | ./deploy.sh
fork/exec ./deploy.sh: exec format error

@zabawaba99
Copy link
Collaborator

I think I would consider more of a caveat than a bug itself. If you don't specify the shebang on a script then it would be the user's responsibility to make sure the file is being fed into the shell of choice.

script:
  - bash deploy.sh

@Tonkpils
Copy link
Owner

Let's go ahead and write a caveat section to mention these.

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

No branches or pull requests

3 participants