如何在 procfile 和 foreman 中使用 Rails 服务器和机器人?

Ama*_*mal 5 ruby ruby-on-rails heroku foreman procfile

我想我的运行rails serverslackbot在两个进程使用Procfilegem 'foreman'

但是当我使用foreman start机器人时,它只运行服务器并没有启动。我尝试删除 line bot 并尝试仅运行 web,但在这种情况下,我的服务器也没有启动它只显示started with pid 1502. 但是当我从另一个终端启动它时,rails s它启动没有问题。我用谷歌搜索了很多,似乎无法找到解决方案。非常感谢帮助。谢谢。

这是我的 Procfile :

web: bundle exec rails server -p $PORT
bot: rails runner -e development slackbot/slack.rb
Run Code Online (Sandbox Code Playgroud)

Kri*_*ris 2

听起来您可能需要指定端口,或者设置环境变量PORT

export PORT=3000
foreman start
Run Code Online (Sandbox Code Playgroud)

或将端口硬编码为Procfile

web: bundle exec rails server -p 3000
Run Code Online (Sandbox Code Playgroud)

或删除该-p选项,在这种情况下将使用默认端口:

web: bundle exec rails server
Run Code Online (Sandbox Code Playgroud)