我正在尝试使用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) 经过几个小时的调试,我终于找到了为什么我的网络应用程序在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吗?
遵循Heroku的入门教程比我预期的更令人沮丧.我现在所拥有的可能是一个配置问题,它可以在不到10次点击的情况下解决,但我不知道这些点击是什么,它正在推动我的问题.
工头不会开始.我没有Ruby,Heroku或Foreman的经验,也没有任何网络编程经验,所以我完全不知道这里发生了什么.这是我得到的错误消息,运行Windows 7 64位:
C:\Users\___________\hello_world_basics>foreman start
09:40:17 web.1 | started with pid 2408
09:40:18 web.1 | Listening on 5000
09:40:18 web.1 |
09:40:18 web.1 | Error: write EINVAL
09:40:18 web.1 | at errnoException (net.js:904:11)
09:40:18 web.1 | at Socket._write (net.js:645:26)
09:40:18 web.1 | at doWrite (_stream_writable.js:226:10)
09:40:18 web.1 | at writeOrBuffer (_stream_writable.js:216:5)
09:40:18 web.1 | at Socket.Writable.write (_stream_writable.js:183:11)
09:40:18 web.1 | at Socket.write (net.js:615:40)
09:40:18 web.1 | at Console.log (console.js:53:16)
09:40:18 web.1 | at Server.<anonymous> (C:\Users\___________\hello_world_basics\web.js:14:11)
09:40:18 web.1 …Run Code Online (Sandbox Code Playgroud) 在使用foremangem时,我遇到了一些问题,它不允许我定义自定义模板.
对于我的一个应用程序,我能够定义〜/ .foreman/templates/upstart/master.conf.erb,它读得很好.然而对于另一个项目,无论我尝试什么,我都无法通过forman upstart导出来获得正确的模板.
我尝试了许多不同的方法来定义-t和--template标志与一个带有〜/ .foreman方法的绝对路径和相对路径的文件.似乎没什么用.
您能否提供一些演示/方案,说明如何使用版本控制目录中的模板定义-t标志(例如在config/upstart-master.conf.erb中)?
foreman start
Run Code Online (Sandbox Code Playgroud)
运行我可以访问localhost的应用程序
如何阻止此操作并返回提示并继续使用heroku?
我在Windows机器上.
这是我在使用Heroku Toolbelt for Node.js运行foreman start时遇到的package.json错误
"dependencies":
{
"express": "~4.4.0",
"jade": "~1.3.1"
}
Run Code Online (Sandbox Code Playgroud)

我使用foreman将我的Procfile导出到一个upstart任务.
Procfile:
web: bundle exec rails server
websocket: bundle exec rails runner websocket-server/em_websocket.rb
Run Code Online (Sandbox Code Playgroud)
其中一个新兴任务(它们非常相似并且失败并出现相同的错误):
start on starting app-web
stop on stopping app-web
respawn
env PORT=5000
setuid app
chdir /var/www/app
exec bundle exec rails server
Run Code Online (Sandbox Code Playgroud)
错误(我通过dmesg得到它):
[35207.676836] init: Failed to spawn app-websocket-1 main process: unable to execute: No such file or directory
[35207.679577] init: Failed to spawn app-web-1 main process: unable to execute: No such file or directory
Run Code Online (Sandbox Code Playgroud)
当我切换到app用户时,我实际上能够bundle exec rails server从给定目录运行.
有什么办法可以将误差再确定一点吗?我没有找到任何相关的登录/var/log/upstart/.
我试图用工头/本町来管理我基于Procfile-Django应用程序.当我启动应用程序查看正常时python manage.py runserver,一切正常.但是,当我通过honcho start或启动应用程序时foreman start web,我收到此错误:
11:59:31 system | web.1 started (pid=27959)
11:59:31 web.1 | [2016-04-26 11:59:31 -0700] [27959] [INFO] Starting gunicorn 19.4.5
11:59:31 web.1 | [2016-04-26 11:59:31 -0700] [27959] [INFO] Listening at: http://0.0.0.0:5000 (27959)
11:59:31 web.1 | [2016-04-26 11:59:31 -0700] [27959] [INFO] Using worker: sync
11:59:31 web.1 | [2016-04-26 11:59:31 -0700] [27962] [INFO] Booting worker with pid: 27962
11:59:31 web.1 | [2016-04-26 18:59:31 +0000] [27962] [ERROR] Exception in worker …Run Code Online (Sandbox Code Playgroud)