在我的本地机器上,我正在尝试启动我的rails应用程序并使用Foreman推迟了工作者.我的Procfile看起来像这样:
web: bundle exec rails server -p $PORT
worker: bundle exec rake jobs:work
Run Code Online (Sandbox Code Playgroud)
当我开始工头时,只有前两个Web请求被执行.第三个请求服务器挂起.第一个请求在控制台输出,第二个请求不输出.
如果我在Procfile中省略了工作人员,服务器运行正常,并将所有内容输出到控制台.此外,当我启动rails服务器和没有Foreman的工作人员一切正常.
所以看起来Foreman存在问题.我猜这是Foreman在第一次请求后没有向控制台输出任何内容的问题,因此缓冲区不会被刷新.我搜索了其他帖子,结果在我的development.rb中添加了STDOUT.sync = true但没有任何成功.
有人有线索吗?谢谢!
继django heroku页面开始逐字逐句. https://devcenter.heroku.com/articles/django
在领班开始步骤,领班没有正确运行.ProcFile内容,
web: gunicorn hellodjango.wsgi
Run Code Online (Sandbox Code Playgroud)
要求内容:
Django==1.5.1
dj-database-url==0.2.1
gunicorn==0.17.4
psycopg2==2.4.5
Run Code Online (Sandbox Code Playgroud)
完全按照下面脚本目录中的tutorial,gunicorn,procfile和requirements进入虚拟env,wsgi.py文件位于带路径的目录hellodjango中 C:\hellodjango2\newvirtualenv\Scripts\hellodjango
python和python/scripts位于pathfile上.
这是输出
(newvirtualenv) C:\hellodjango2\newvirtualenv\Scripts>foreman start
09:48:58 web.1 | started with pid 3580
09:48:58 web.1 | exited with code 1
09:48:58 system | sending SIGKILL to all processes
Run Code Online (Sandbox Code Playgroud) 我正在尝试设置一个Heroku-ready Flask应用程序,但我无法弄清楚如何打开日志记录.
如果没有Foreman,我可以创建一个helloworld应用程序,如Flask教程中所述:
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
app.logger.debug('A value for debugging')
app.logger.warning('A value for warning')
return "Hello World!"
if __name__ == "__main__":
app.run(debug=True)
Run Code Online (Sandbox Code Playgroud)
像这样开始:
python hello.py
Run Code Online (Sandbox Code Playgroud)
并登录stdout.
但是,当我遵循Heroku教程时,没有app.run线:
import os
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello():
app.logger.debug('A value for debugging')
app.logger.warning('A value for warning')
return 'Hello World!'
Run Code Online (Sandbox Code Playgroud)
所以我无法弄清楚如何在调试模式下运行和/或获取日志输出:
foreman start -p 5000
Run Code Online (Sandbox Code Playgroud)
Procfile:
web: gunicorn hello:app
Run Code Online (Sandbox Code Playgroud) 我是Rails上使用foreman gem的新手.我在Rails 3.2,Ruby 1.9.3和Foreman 0.6上运行了一个应用程序.我想知道当我管理工头时幕后发生的事情.具体来说,运行foreman run rails s与foreman start本地终端之间的差异.
我已经注意到了一些差异.例如,工人只在跑步时跑,foreman start而不是在跑步时跑foreman run rails s.但我想知道具体细节.哪里可以阅读更多关于这个,或者有人可以解释它是如何工作的?
我正在尝试使用Foreman(版本0.31.0)来管理我们的应用程序的进程,但我对nginx(nginx/1.0.10 + Phusion Passenger 3.0.11)没有太多运气.
这是我的Procfile中的相关行:
nginx: sudo /home/ubuntu/nginx/sbin/nginx
Run Code Online (Sandbox Code Playgroud)
当我启动应用程序时,Foreman报告nginx已启动,然后立即终止:
$ foreman start
21:18:28 nginx.1 | started with pid 27347
21:18:28 nginx.1 | process terminated
21:18:28 system | sending SIGTERM to all processes
Run Code Online (Sandbox Code Playgroud)
但是,即使Foreman另有报告,nginx实际上仍在运行.
同样,如果我导出到Upstart:
rvmsudo foreman export upstart /etc/init -a my_app -u ubuntu
Run Code Online (Sandbox Code Playgroud)
并运行sudo start my_app,nginx正常启动.但sudo stop my_app 不会阻止nginx.它继续运行.
让nginx与Foreman合作是否有诀窍?
注意:我发现Foreman的这个问题,我想知道它是否相关.
我最近从使用Ubuntu系统Ruby转向使用RVM.当我运行时foreman start,无论命令在我的Procfile中是什么,我都会得到一个未找到的错误.
我目前的Procfile是:
web: bundle exec unicorn -p $PORT -c ./unicorn.rb
Run Code Online (Sandbox Code Playgroud)
所以错误是:
/home/timmillwood/.rvm/gems/ruby-1.9.3-p327/gems/foreman-0.60.2/bin/foreman-runner: 41: exec: bundle: not found
Run Code Online (Sandbox Code Playgroud)
which foreman 回报
/home/timmillwood/.rvm/gems/ruby-1.9.3-p327/bin/foreman
Run Code Online (Sandbox Code Playgroud)
which bundle 回报
/home/timmillwood/.rvm/gems/ruby-1.9.3-p327/bin/bundle
Run Code Online (Sandbox Code Playgroud)
输出来自rvm info:
ruby-1.9.3-p327:
system:
uname: "Linux ubuntu 3.5.0-19-generic #30-Ubuntu SMP Tue Nov 13 17:48:01 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux"
system: "ubuntu/12.10/x86_64"
bash: "/bin/bash => GNU bash, version 4.2.37(1)-release (x86_64-pc-linux-gnu)"
zsh: " => not installed"
rvm:
version: "rvm 1.17.3 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]"
updated: …Run Code Online (Sandbox Code Playgroud) 我目前正在运行Foreman on staging(Ubuntu),一旦我开始工作就会切换到使用upstart.
我的Procfile.staging看起来像这样:
nginx: sudo service nginx start
unicorn: bundle exec unicorn -c ./config/unicorn.rb
redis: bundle exec redis-server
sidekiq: bundle exec sidekiq -v -C ./config/sidekiq.yml
Run Code Online (Sandbox Code Playgroud)
我可以使用以下命令成功启动nginx:
$ sudo service nginx start
Run Code Online (Sandbox Code Playgroud)
但是当我运行$ foreman start时,其他三个进程成功启动,nginx不会:
11:15:46 nginx.1 | started with pid 15966
11:15:46 unicorn.1 | started with pid 15968
11:15:46 redis.1 | started with pid 15971
11:15:46 sidekiq.1 | started with pid 15974
11:15:46 nginx.1 | Starting nginx: nginx.
11:15:46 nginx.1 | exited with code 0
11:15:46 …Run Code Online (Sandbox Code Playgroud) 经过几个小时的调试,我终于找到了为什么我的网络应用程序在Windows上崩溃的原因.NPM依赖有时会记录消息console.error,并且在运行Foreman + Nodemon组合时,这似乎在OSX和Windows上有不同的行为.
也许对这些工具有更多了解的人可以帮助解释一下这个问题?这是一个简单的应用程序来说明它:
app.js
console.log('1');
console.error('2');
console.log('3');
Run Code Online (Sandbox Code Playgroud)
nodemon --exec node app.js在OSX和Windows 7上运行正常,并提供预期的输出:
18 Feb 23:56:25 - [nodemon] v0.6.23
18 Feb 23:56:26 - [nodemon] watching: C:\project
18 Feb 23:56:26 - [nodemon] starting `node app.js`
1
2
3
18 Feb 23:56:26 - [nodemon] clean exit - waiting for changes before restart
Run Code Online (Sandbox Code Playgroud)
现在,使用Foreman和Procfile包装调用,它看起来像这样:
# Procfile
app: nodemon --exec node app.js
Run Code Online (Sandbox Code Playgroud)
在OSX上:
> foreman start
23:59:12 app.1 | started with pid 69229
23:59:12 app.1 | 18 Feb 23:59:12 …Run Code Online (Sandbox Code Playgroud) 我正在与Flask和Foreman一起为Heroku托管.我开始本地服务器输入foreman start.我的问题是,我想查看我的代码生成的日志错误消息,但我没有找到正确的方法来执行此操作.
我尝试使用我在Flask文档中找到的一些代码,但它不起作用:
import logging
from FileHandler import FileHandler
file_handler = FileHandler("log.txt")
file_handler.setLevel(logging.WARNING)
app.logger.addHandler(file_handler)
Run Code Online (Sandbox Code Playgroud)
知道如何在运行Flask时能够读取de错误消息foreman start吗?
我有Procfile一个启动rails服务器和gulp监视任务.独立运行,这些任务使用颜色格式化其输出.在福尔曼内部,他们没有.
根据这个答案,我猜我需要传递参数rails s以及gulp保留颜色.这是真的,还是可能与工头争论?
如果不是,为了这个目的,我会将哪些参数传递给rails和gulp?