我的 Ruby on Rails 应用程序使用 foreman (https://github.com/ddollar/foreman) 来管理在运行应用程序时需要启动的进程。
我的 Procfile
如下所示:
precompile: bundle exec rake assets:precompile
web: bundle exec puma -e $PUMA_ENV
worker: bundle exec rake jobs:work
search: bundle exec rake sunspot:solr:run
在加入第一行代码(precompile
任务)之前,运行$ foreman start
是按照预期工作的。
当我运行$ foreman start
时,我的输出如下:
$ foreman start -e .env.dev
10:30:20 precompile.1 | started with pid 7309
10:30:20 web.1 | started with pid 7310
10:30:20 worker.1 | started with pid 7311
10:30:20 search.1 | started with pid 7312
10:30:22 web.1 | [7310] Puma starting in cluster mode...
10:30:22 web.1 | [7310] * Version 2.8.2 (ruby 2.1.0-p0), codename: Sir Edmund Percival Hillary
10:30:22 web.1 | [7310] * Min threads: 4, max threads: 16
10:30:22 web.1 | [7310] * Environment: development
10:30:22 web.1 | [7310] * Process workers: 2
10:30:22 web.1 | [7310] * Phased restart available
10:30:22 web.1 | [7310] * Listening on tcp://0.0.0.0:3000
10:30:22 web.1 | [7310] Use Ctrl-C to stop
10:30:23 web.1 | [7313] + Gemfile in context: /Users/username/rails_projects/lcms/Gemfile
10:30:23 web.1 | [7314] + Gemfile in context: /Users/username/rails_projects/lcms/Gemfile
10:30:30 web.1 | [7310] - Worker 1 (pid: 7314) booted, phase: 0
10:30:30 worker.1 | [Worker(host:MacBook-Pro.local pid:7311)] Starting job worker
10:30:30 web.1 | [7310] - Worker 0 (pid: 7313) booted, phase: 0
10:30:32 precompile.1 | exited with code 0
10:30:32 system | sending SIGTERM to all processes
SIGTERM received
10:30:32 web.1 | [7310] - Gracefully shutting down workers...
10:30:32 worker.1 | [Worker(host:MacBook-Pro.local pid:7311)] Exiting...
10:30:32 search.1 | exited with code 143
10:30:32 web.1 | [7310] - Goodbye!
10:30:32 web.1 | exited with code 0
10:30:33 worker.1 | exited with code 0
我不知道如何获取有关该问题的更多详细信息。 我已将$stdout.sync = true
添加到我的config/environments/development.rb
中,并且输出与未添加时相同。
我还尝试了在precompile任务中附加和预置RAILS_ENV=development
和RAILS_ENV=production
。
如何设置我的foreman / Procfile以成功预编译资产,然后继续执行启动应用程序的其他任务?
10:30:32 precompile.1 | exited with code 0
是rake assets:precompile
任务的结束,退出码为0告诉foreman杀死所有进程。我不确定如何覆盖它,即使我知道,我也不知道是否明智。 - sealocal