foreman 只显示以 “started with pid #” 开头的行没有别的
当我运行 foreman 时,我得到以下信息:
> foreman start
16:47:56 web.1 | started with pid 27122
只有当我停止它(通过 ctrl-c)时,它才会向我显示缺少的内容:
^CSIGINT received
16:49:26 system | sending SIGTERM to all processes
16:49:26 web.1 | => Booting Thin
16:49:26 web.1 | => Rails 3.0.0 application starting in development on http://0.0.0.0:5000
16:49:26 web.1 | => Call with -d to detach
16:49:26 web.1 | => Ctrl-C to shutdown server
16:49:26 web.1 | >> Thin web server (v1.3.1 codename Triple Espresso)
16:49:26 web.1 | >> Maximum connections set to 1024
16:49:26 web.1 | >> Listening on 0.0.0.0:5000, CTRL+C to stop
16:49:26 web.1 | >> Stopping ...
16:49:26 web.1 | Exiting
16:49:26 web.1 | >> Stopping ...
如何修复它?
When I run foreman I get the following:
> foreman start
16:47:56 web.1 | started with pid 27122
Only if I stop it (via ctrl-c) it shows me what is missing:
^CSIGINT received
16:49:26 system | sending SIGTERM to all processes
16:49:26 web.1 | => Booting Thin
16:49:26 web.1 | => Rails 3.0.0 application starting in development on http://0.0.0.0:5000
16:49:26 web.1 | => Call with -d to detach
16:49:26 web.1 | => Ctrl-C to shutdown server
16:49:26 web.1 | >> Thin web server (v1.3.1 codename Triple Espresso)
16:49:26 web.1 | >> Maximum connections set to 1024
16:49:26 web.1 | >> Listening on 0.0.0.0:5000, CTRL+C to stop
16:49:26 web.1 | >> Stopping ...
16:49:26 web.1 | Exiting
16:49:26 web.1 | >> Stopping ...
How do I fix it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
我已经能够通过两种不同的方式解决这个问题:
来自https:// /github.com/ddollar/foreman/wiki/Missing-Output:
<块引用>
如果您没有看到程序的任何输出,则可能是
它有可能缓冲标准输出。 Ruby 默认缓冲 stdout。到
禁用此行为,请尽早在您的
程序:
<前><代码># 红宝石
$stdout.sync = true
通过 heroku toolbelt 包安装 foreman
但我仍然不知道发生了什么,也不知道为什么上述两种方法解决了问题......
I’ve been able to resolve this issue by 2 different ways:
From https://github.com/ddollar/foreman/wiki/Missing-Output:
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…
我的解决方案是将 $stdout.sync = true 放在 config/environments/development.rb 的顶部。
那么加载开发环境的所有内容(包括thin)都不会缓冲stdout。
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 将向终端输出显示其启动的进程写入标准输出的任何内容。” - ddollar 请参阅 foreman-issues#57
顺便说一句,您可以在 Procfile 中使用 tailf 来查看日志
提示:OSX 中不存在 tailf,使用 tail -f -n 40 log/development.log 可以。
"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
Tip: tailf doesn't exist in OSX, using tail -f -n 40 log/development.log works.
我也遇到了同样的问题,但有不同的解决方案。 (ruby 1.9.2p290、rails 3.1.0、ubuntu 10.04.3)
我将 Procfile 中的行从: 更改
为:
它不再给我带来问题。
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:
to:
and it no longer gave me an issue.
我有同样的问题(ruby 1.9.3-p0、rails 3.2rc2、OSX 10.7)。
通过使用 foreman-0.27.0 将此行添加到我的 Gemfile 中解决了该问题。
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.
如果您使用 Foreman 运行 Python 项目而不是 Ryby 项目,并且遇到同样的问题,这里有一些适合您的解决方案。如果您使用 Procfile 直接调用 python CLI,则可以使用 '-u' 选项来避免 stdout 缓冲:
如果您使用 Procfile 来管理 WSGI 服务器,例如调用 Gunicorn、flask、bottle、eve等,那么你可以在你的python项目的根目录中添加一个“.env”文件,其中包含以下内容:
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:
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: