Foreman: Tried $stdout.sync = true, and foreman is still not getting output.

Created on 10 Jul 2012  ·  17Comments  ·  Source: ddollar/foreman

I am not getting output from foreman except "started {process} with {pid}", any help would be greatly appreciated.

My applications are set to log to STDOUT and I have the following at the top of my config.ru:

$stdout.sync=true

# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment',  __FILE__)
run ItriageServer::Application

My Procfile is as follows:

# Apps
itriage:            subcontract -d itriage3 --signal INT -- bundle exec thin start -p 5001
api_clinical:       subcontract -d api-clinical --signal INT -- bundle exec rails s -p 5002
api_global_search:  subcontract -d api-global-search --signal INT -- bundle exec rails s -p 5003
auth_server:        subcontract -d itriage-auth --signal INT -- bundle exec rails s -p 5004

# Proxy
haproxy:            haproxy -f itriage-runlocal/config/haproxy.cfg

# Search
solr:               subcontract -d itriage3 --signal INT -- bundle exec rake sunspot:solr:run
sphinx:             subcontract -d itriage3 --signal INT -- bundle exec rake ts:run_in_foreground

Most helpful comment

A hack that worked for me was to change a line in https://github.com/ddollar/foreman/blob/v0.82.0/lib/foreman/engine.rb#L359 :

In line pid = process.run(:output => writer, :env => { changing :output => writer to :output => $stdout worked.

All 17 comments

What is subcontract? Is it possible that it's buffering the output?

I installed foreman through the Heroku toolbelt. I’m seeing stdout from a Python process be cut in half (only the first 20 lines or so from error tracebacks). Foreman appears to be version 0.44.0.

I have already set PYTHONUNBUFFERED=true in my .env.

I'm seeing the same thing as @jokull. It only happened when I started running a longer process, but the output gets cut at some point and stops printing. The odd thing is that the spot in the code where the output stops seems to change each time I run my code. I've also set PYTHONUNBUFFERED=true.

same issue

I've got the same issue here, PYTHONUNBUFFERED=true, still no output other than startup stuff.

I found the issue for my python friends. You need to set PYTHONUNBUFFERED=True in .env for output to come normally with a capital T in True.

Updated the wiki to reflect this https://github.com/ddollar/foreman/wiki/Missing-Output

@imkevinxu The problem we python folks are seeing persists even with PYTHONUNBUFFERED=true

I gave up and used Honcho

@evanhammer try setting PYTHONUNBUFFERED to True instead of true

@imkevinxu It's an environmental variable so it shouldn't matter but I've tried both ways. This issue isn't about the normal pythonunbuffered issue. This is an issue with multiple processes running even when setting that variable.

@jokull I also switched to Honcho.

@evanhammer Hmmm... okay fair enough. Using True seemed to make it work for me though, I'm seeing all the output immediately now

True doesn't work for me either, also switched to Honcho.

Any news on this? I've been fighting with the same problem for the past 2 hours.

$stdout.sync = true # in config/environments/development.rb, tried in config.ru too

Procfile:

web: bundle exec rails server thin start -p $PORT
guard: bundle exec guard
redis: redis-server ./config/redis/development.conf
worker: bundle exec sidekiq -C ./config/sidekiq.yml -r ./config/environment.rb

Guard outputs fine, but thin and sidekiq don't, yet show up when exited.

Honcho's giving me better results in local testing as well...going to stick with that for now

Ruby sucks at stdin and interactive processes, not really possible to fix this one.

Check out https://github.com/ddollar/forego for another alternative

A hack that worked for me was to change a line in https://github.com/ddollar/foreman/blob/v0.82.0/lib/foreman/engine.rb#L359 :

In line pid = process.run(:output => writer, :env => { changing :output => writer to :output => $stdout worked.

The only solution that worked for me is what @bikramwp has posted. Any reason why this is not fixed in master?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

corydolphin picture corydolphin  ·  30Comments

millisami picture millisami  ·  3Comments

jt2190 picture jt2190  ·  9Comments

rvanlieshout picture rvanlieshout  ·  3Comments

maxehmookau picture maxehmookau  ·  5Comments