foreman only shows line with “started with pid #” and nothing else

梦想的初衷 提交于 2019-11-28 04:04:36

I’ve been able to resolve this issue by 2 different ways:

  1. From https://github.com/ddollar/foreman/wiki/Missing-Output:

    If you are not seeing any output from your program, there is a likely chance that it is buffering stdout. Ruby buffers stdout by default. To disable this behavior, add this code as early as possible in your program:

    # ruby
    $stdout.sync = true
    
  2. By installing foreman via the heroku toolbelt package

But I still don’t know what’s happening nor why this 2 ways above resolved the issue…

My solution was to put $stdout.sync = true at the top of config/environments/development.rb.

Then everything that loads the development environment (incluing thin) will not buffer stdout.

"Foreman will display to the terminal output anything written to stdout by the processes it launches." - ddollar See foreman-issues#57

BTW, you can use tailf into Procfile to see logs

web: bundle exec rails server thin -p $PORT
log: tail -f log/development.log

Tip: tailf doesn't exist in OSX, using tail -f -n 40 log/development.log works.

If you are using Foreman to run a Python project, rather than a Ryby project, and you're having the same issue, here are some solutions for you. If you are using a Procfile to invoke the python CLI directly, then you can use the '-u' option to avoid stdout buffering:

python -u script.py

If you are using a Procfile to manage a WSGI server, such as invoking gunicorn, flask, bottle, eve, etc., then you can add a ".env" file to the root of your python project, containing the following:

PYTHONUNBUFFERED=True

I have the same problem (ruby 1.9.3-p0, rails 3.2rc2, OSX 10.7).

Resolved the issue by using foreman-0.27.0 by adding this line into my Gemfile.

gem 'foreman', '0.27.0'

I also had the same problem but with a different solution. (ruby 1.9.2p290, rails 3.1.0, ubuntu 10.04.3)

I changed the line in my Procfile from:

web: bundle exec thin start -p $PORT

to:

web: bundle exec rails server thin -p $PORT

and it no longer gave me an issue.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!