foreman 只显示以 “started with pid #” 开头的行没有别的

发布于 2024-12-24 18:55:38 字数 846 浏览 5 评论 0原文

当我运行 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

孤芳又自赏 2024-12-31 18:55:38

我已经能够通过两种不同的方式解决这个问题:

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

    <块引用>

    如果您没有看到程序的任何输出,则可能是
    它有可能缓冲标准输出。 Ruby 默认缓冲 stdout。到
    禁用此行为,请尽早在您的
    程序:

    <前><代码># 红宝石
    $stdout.sync = true

  2. 通过 heroku toolbelt 包安装 foreman

但我仍然不知道发生了什么,也不知道为什么上述两种方法解决了问题......

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…

記憶穿過時間隧道 2024-12-31 18:55:38

我的解决方案是将 $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.

白衬杉格子梦 2024-12-31 18:55:38

“Foreman 将向终端输出显示其启动的进程写入标准输出的任何内容。” - ddollar 请参阅 foreman-issues#57

顺便说一句,您可以在 Procfile 中使用 tailf 来查看日志

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

提示: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

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.

禾厶谷欠 2024-12-31 18:55:38

我也遇到了同样的问题,但有不同的解决方案。 (ruby 1.9.2p290、rails 3.1.0、ubuntu 10.04.3)

我将 Procfile 中的行从: 更改

web: bundle exec thin start -p $PORT

为:

web: bundle exec rails server thin -p $PORT

它不再给我带来问题。

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.

世界等同你 2024-12-31 18:55:38

我有同样的问题(ruby 1.9.3-p0、rails 3.2rc2、OSX 10.7)。

通过使用 foreman-0.27.0 将此行添加到我的 Gemfile 中解决了该问题。

gem 'foreman', '0.27.0'

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'
没有你我更好 2024-12-31 18:55:38

如果您使用 Foreman 运行 Python 项目而不是 Ryby 项目,并且遇到同样的问题,这里有一些适合您的解决方案。如果您使用 Procfile 直接调用 python CLI,则可以使用 '-u' 选项来避免 stdout 缓冲:

python -u script.py

如果您使用 Procfile 来管理 WSGI 服务器,例如调用 Gunicorn、flask、bottle、eve等,那么你可以在你的python项目的根目录中添加一个“.env”文件,其中包含以下内容:

PYTHONUNBUFFERED=True

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文