使用Foreman启动Rails时丢失端口

时间:2015-10-08 13:08:53

标签: ruby-on-rails ruby foreman

我是RoR的新手,我正在尝试安装特定的项目。我的操作系统是Ubuntu 14.04,我试图从终端运行该项目。我已按照项目规范安装了所有需要的宝石。

问题

当我运行试图运行项目的命令时

foreman start -f Procfile.dev

它给我以下错误

17:01:33 web.1    | started with pid 4538
17:01:33 worker.1 | started with pid 4540
17:01:34 web.1    | /home/user/.rvm/gems/ruby-2.1.3/gems/railties-4.0.9/lib/rails/commands/server.rb:33:in `parse!': missing argument: --port (OptionParser::MissingArgument)
17:01:34 web.1    |     from /home/user/.rvm/gems/ruby-2.1.3/gems/rack-1.5.2/lib/rack/server.rb:293:in `parse_options'
17:01:34 web.1    |     from /home/user/.rvm/gems/ruby-2.1.3/gems/rack-1.5.2/lib/rack/server.rb:184:in `options'
17:01:34 web.1    |     from /home/user/.rvm/gems/ruby-2.1.3/gems/railties-4.0.9/lib/rails/commands/server.rb:58:in `set_environment'
17:01:34 web.1    |     from /home/user/.rvm/gems/ruby-2.1.3/gems/railties-4.0.9/lib/rails/commands/server.rb:42:in `initialize'
17:01:34 web.1    |     from /home/user/.rvm/gems/ruby-2.1.3/gems/railties-4.0.9/lib/rails/commands.rb:71:in `new'
17:01:34 web.1    |     from /home/user/.rvm/gems/ruby-2.1.3/gems/railties-4.0.9/lib/rails/commands.rb:71:in `<top (required)>'
17:01:34 web.1    |     from bin/rails:4:in `require'
17:01:34 web.1    |     from bin/rails:4:in `<main>'
17:01:34 web.1    | exited with code 1
17:01:34 system   | sending SIGTERM to all processes
17:01:34 worker.1 | terminated by SIGTERM

这就是我在Procfile.dev中所拥有的:

web: bundle exec rails s --port $DEV_PORT
worker: bundle exec rake jobs:work
# exec: lt --port $DEV_PORT --subdomain $SUBDOMAIN

你能告诉我如何解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

Foreman设置一个名为$PORT的环境变量,而不是$DEV_PORT。除非你自己设置$DEV_PORT(如果你需要像Heroku那样部署它,这将无效),你明确地用空端口启动你的进程。将您的Procfile更改为使用$PORT,您应该好好去。