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

Forman makes $stdin appear to be a TTY. #99

Closed
leehambley opened this issue Nov 28, 2011 · 7 comments
Closed

Forman makes $stdin appear to be a TTY. #99

leehambley opened this issue Nov 28, 2011 · 7 comments

Comments

@leehambley
Copy link

I believe this is a bug, as some programs (ruby-debug) assume this means they can ask for user input, which isn't true when running under foreman.

Test Case:

# Procfile
tty: ruby -e 'puts $stdin.tty?'

The output for me, unfortunately is true. I believe this caused #58 (ruby-debug related).

It should be an easy fix, and would enable the proposed solution there to be modified to:

Debugger.start_remote unless $stdin.tty?

Ensuring we could have a remote debugger under foreman ( and production, staging, etc ) - but an inline debugger in rake and other runners.

Note: I haven't checked if ruby-debug actually honors $stdin.tty?, and I don't know if this is an easy fix for foreman.

I'm also certain that ruby-deubg isn't the only usecase for this.

@ddollar
Copy link
Owner

ddollar commented Nov 28, 2011

Foreman uses the PTY library in Ruby to intentionally appear to each fork to be an interactive user. When Ruby is not faced with an interactive user on $stdout, it buffers. I originally used PTY to work around this so that Ruby programs would display their output in realtime rather than buffer. I'm beginning to rethink this decision.

I'd be open to some investigation on how to change over to another open/fork mechanism. Ideally we could actually pull this functionality out into its own class/engine so that we could have swappable backends for JRuby (use Java threads instead of forking?) etc.

I believe this is what is causing #94 as well. It appears that PTY is launching the subprocess inside of sh whenever the command line contains a $. This is preventing SIGTERM from propagating down to the subprocess since sh swallows it.

Any chance you'd be interested in helping out on some of this?

@leehambley
Copy link
Author

@ddollar, it's not exactly my area of expertise, but it's a common problem
(PTY vs. not) for Capistrano, another problem that is my responsibility to
fix - so I'd be more than happy to dive into it with you at least for the
learning, message me on Github, and let's take the gritty details offline,
maybe we can remote-pair, somehow.

@ddollar
Copy link
Owner

ddollar commented Dec 9, 2011

I just pushed a prerelease of foreman that should fix this. Please try it and let me know if it works for you.

$ gem install foreman --pre

@leehambley
Copy link
Author

Given my trivial testing thus far David, it seems good to me.

@brianewing
Copy link

Output for me is now buffered - I can't tell when all my things have started, can't see the last request, etc, which is somewhat annoying. Is this now intended?

@ddollar
Copy link
Owner

ddollar commented Jan 22, 2012

Hey there,

Check out https://github.com/ddollar/foreman/wiki/Missing-Output for instructions on how to make your process not buffer.

Cheers,
David

@ddollar ddollar closed this as completed Jan 22, 2012
@brianewing
Copy link

Cool, thanks :)

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