Ich versuche, eine Rails-App auf Puma und Jruby zu implementieren. die procfile ist wie folgtFehler bei der Bereitstellung von Schienen App auf Puma in Heroku
web: bundle exec puma -C config/puma.rb -p $PORT -e $RACK_ENV
Konfiguration für Puma platziert in
config/puma.rb
if ENV['RACK_ENV'] != 'production' || ENV['RAILS_ENV'] != 'production'
workers Integer(ENV['PUMA_WORKERS'] || 4)
end
threads Integer(ENV['MIN_THREADS'] || 1), Integer(ENV['MAX_THREADS'] || 4)
rackup DefaultRackup
port ENV['PORT'] || 3000
environment ENV['RACK_ENV'] || 'development'
preload_app!
on_worker_boot do
# worker specific setup
ActiveSupport.on_load(:active_record) do
config = ActiveRecord::Base.configurations[Rails.env] ||
Rails.application.config.database_configuration[Rails.env]
config['pool'] = ENV['MAX_THREADS'] || 16
ActiveRecord::Base.establish_connection(config)
end
end
der Grund, warum ich eine bedingte Initialisierung für die Arbeitnehmer haben wird, weil Heroku beklagt (oder kann Puma sein) Worker-Modus ist nicht für JRuby und Windows verfügbar; wie auch immer,
Das seltsame Verhalten, das ich auf Heroku bemerken ist, dass (im Gegensatz zu) meiner lokalen Umgebung einer Clustered-Puma-Instanz ohne Probleme gestartet wird, und nimmt zwei verschiedene Ports dh 3000 und 5000.
jedoch zu binden, auf Produktion zB Heroku dies verursacht einen Absturz
2014-06-23T08:50:54.545724+00:00 heroku[web.1]: State changed from crashed to starting
2014-06-23T08:51:02.510184+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Djava.rmi.server.useCodebaseOnly=true
2014-06-23T08:51:01.333763+00:00 heroku[web.1]: Starting process with command `bundle exec puma -C config/puma.rb -p 49576 -e production`
2014-06-23T08:51:21.658663+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Djava.rmi.server.useCodebaseOnly=true
2014-06-23T08:51:44.964380+00:00 app[web.1]: * Version 2.8.2 (jruby 1.9.3), codename: Sir Edmund Percival Hillary
2014-06-23T08:51:44.962724+00:00 app[web.1]: The signal USR1 is in use by the JVM and will not work correctly on this platform
2014-06-23T08:51:44.964563+00:00 app[web.1]: * Min threads: 1, max threads: 4
2014-06-23T08:51:44.964738+00:00 app[web.1]: * Environment: production
2014-06-23T08:51:44.963925+00:00 app[web.1]: Puma starting in single mode...
2014-06-23T08:51:57.852471+00:00 app[web.1]: Errno::EADDRINUSE: Address already in use - bind - Address already in use
2014-06-23T08:51:57.830580+00:00 app[web.1]: * Listening on tcp://0.0.0.0:49576
2014-06-23T08:51:57.852474+00:00 app[web.1]: initialize at org/jruby/ext/socket/RubyTCPServer.java:118
2014-06-23T08:51:57.852478+00:00 app[web.1]: add_tcp_listener at /app/vendor/bundle/jruby/1.9/gems/puma-2.8.2-java/lib/puma/binder.rb:195
2014-06-23T08:51:57.852476+00:00 app[web.1]: new at org/jruby/RubyIO.java:852
2014-06-23T08:51:57.850256+00:00 app[web.1]: * Listening on tcp://0.0.0.0:49576
2014-06-23T08:51:57.852479+00:00 app[web.1]: parse at /app/vendor/bundle/jruby/1.9/gems/puma-2.8.2-java/lib/puma/binder.rb:96
2014-06-23T08:51:57.852481+00:00 app[web.1]: each at org/jruby/RubyArray.java:1613
2014-06-23T08:51:57.852482+00:00 app[web.1]: parse at /app/vendor/bundle/jruby/1.9/gems/puma-2.8.2-java/lib/puma/binder.rb:82
2014-06-23T08:51:57.852484+00:00 app[web.1]: load_and_bind at /app/vendor/bundle/jruby/1.9/gems/puma-2.8.2-java/lib/puma/runner.rb:119
2014-06-23T08:51:57.852486+00:00 app[web.1]: run at /app/vendor/bundle/jruby/1.9/gems/puma-2.8.2-java/lib/puma/single.rb:73
2014-06-23T08:51:57.852487+00:00 app[web.1]: run at /app/vendor/bundle/jruby/1.9/gems/puma-2.8.2-java/lib/puma/cli.rb:499
2014-06-23T08:51:57.852489+00:00 app[web.1]: (root) at /app/vendor/bundle/jruby/1.9/gems/puma-2.8.2-java/bin/puma:10
2014-06-23T08:51:57.852491+00:00 app[web.1]: load at org/jruby/RubyKernel.java:1099
2014-06-23T08:51:57.852492+00:00 app[web.1]: (root) at /app/vendor/bundle/jruby/1.9/bin/puma:23
2014-06-23T08:51:59.347012+00:00 heroku[web.1]: State changed from starting to crashed
2014-06-23T08:51:59.333790+00:00 heroku[web.1]: Process exited with status 1
Dieses seltsame Startverhalten ist nicht zu sehen, wenn ich es auf meinem Laptop laufen.
Der einzige Weg, ich Puma arbeitet an jruby in Heroku bekommen haben, ist durch diese
if ENV['RACK_ENV'] != 'production' || ENV['RAILS_ENV'] != 'production'
workers Integer(ENV['PUMA_WORKERS'] || 4)
port ENV['PORT'] || 3000
environment ENV['RACK_ENV'] || 'development'
end
threads Integer(ENV['MIN_THREADS'] || 1), Integer(ENV['MAX_THREADS'] || 4)
rackup DefaultRackup
preload_app!
on_worker_boot do
# worker specific setup
ActiveSupport.on_load(:active_record) do
config = ActiveRecord::Base.configurations[Rails.env] ||
Rails.application.config.database_configuration[Rails.env]
config['pool'] = ENV['MAX_THREADS'] || 16
ActiveRecord::Base.establish_connection(config)
end
end
dh wenn die Port und Umgebung
Einstellung Richtlinien aus der Seite sind die, wenn Block Heroku versucht irgendwie zwei Instanzen auf demselben laufen Port, der offensichtlich einen Absturz verursacht.Bin ich jede Konfiguration hier fehlt oder grundsätzlich in Clustered-Modus ausgeführt wird (ich habe sogar versucht 2.0.0 statt JRuby Ruby läuft) ist einfach nicht möglich, in Heroku
* Update *
procfile
web: bundle exec puma -C config/puma.rb
config/puma.rb
if ENV['RACK_ENV'] != 'production' || ENV['RAILS_ENV'] != 'production'
workers Integer(ENV['PUMA_WORKERS'] || 4)
end
threads Integer(ENV['MIN_THREADS'] || 1), Integer(ENV['MAX_THREADS'] || 16)
rackup DefaultRackup
port ENV['PORT'] || 3000
environment ENV['RACK_ENV'] || 'development'
preload_app!
on_worker_boot do
# worker specific setup
ActiveSupport.on_load(:active_record) do
config = ActiveRecord::Base.configurations[Rails.env] ||
Rails.application.config.database_configuration[Rails.env]
config['pool'] = ENV['MAX_THREADS'] || 16
ActiveRecord::Base.establish_connection(config)
end
end
Der Grund für die bedingten Block (von dem ersten Problembeschreibung
zitierte der Grund, warum ich eine bedingte Initialisierung für die Arbeitnehmer ist, weil Heroku beklagt (oder kann Puma) Arbeiter-Modus für nicht verfügbar ist JRuby und Windows;
und Fehlerprotokolle (auch wenn ich JRuby, die bedingte Arbeiter Block entfernen) und versuchen, auf geclusterten Modus
606 2014-06-23T07:13:42.058507+00:00 heroku[api]: Release v35 created by [email protected]
607 2014-06-23T07:13:47.674708+00:00 app[web.1]: [2] Puma starting in cluster mode...
608 2014-06-23T07:13:47.674777+00:00 app[web.1]: [2] * Version 2.8.2 (ruby 2.1.1-p76), codename: Sir Edmund Percival Hillary
609 2014-06-23T07:13:47.674816+00:00 app[web.1]: [2] * Min threads: 1, max threads: 16
610 2014-06-23T07:13:47.674939+00:00 app[web.1]: [2] * Preloading application
611 2014-06-23T07:13:47.674858+00:00 app[web.1]: [2] * Environment: production
612 2014-06-23T07:13:47.674900+00:00 app[web.1]: [2] * Process workers: 4
613 2014-06-23T07:13:49.078330+00:00 app[web.1]: [2] * Listening on tcp://0.0.0.0:45245
614 2014-06-23T07:13:49.078766+00:00 app[web.1]: /app/vendor/bundle/ruby/2.1.0/gems/puma-2.8.2/lib/puma/binder.rb:195:in `initialize': Address already in use - bind(2) for "0.0.0.0 " port 45245 (Errno::EADDRINUSE)
615 2014-06-23T07:13:49.078775+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.1.0/gems/puma-2.8.2/lib/puma/binder.rb:195:in `add_tcp_listener'
616 2014-06-23T07:13:49.078771+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.1.0/gems/puma-2.8.2/lib/puma/binder.rb:195:in `new'
617 2014-06-23T07:13:49.078780+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.1.0/gems/puma-2.8.2/lib/puma/binder.rb:82:in `each'
618 2014-06-23T07:13:49.078785+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.1.0/gems/puma-2.8.2/lib/puma/runner.rb:119:in `load_and_bind'
619 2014-06-23T07:13:49.078778+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.1.0/gems/puma-2.8.2/lib/puma/binder.rb:96:in `block in parse'
620 2014-06-23T07:13:49.078784+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.1.0/gems/puma-2.8.2/lib/puma/binder.rb:82:in `parse'
621 2014-06-23T07:13:49.078793+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.1.0/gems/puma-2.8.2/lib/puma/cli.rb:499:in `run'
622 2014-06-23T07:13:49.078789+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.1.0/gems/puma-2.8.2/lib/puma/cluster.rb:271:in `run'
623 2014-06-23T07:13:49.078794+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.1.0/gems/puma-2.8.2/bin/puma:10:in `<top (required)>'
624 2014-06-23T07:13:49.078798+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.1.0/bin/puma:23:in `load'
625 2014-06-23T07:13:49.078801+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.1.0/bin/puma:23:in `<main>'
626 2014-06-23T07:13:49.078565+00:00 app[web.1]: [2] * Listening on tcp://0.0.0.0:45245
627 2014-06-23T07:13:50.359244+00:00 heroku[web.1]: Process exited with status 1
628 2014-06-23T07:13:45.838792+00:00 heroku[web.1]: Starting process with command `bundle exec puma -C config/puma.rb -p 45245 -e production`
629 2014-06-23T07:13:50.385427+00:00 heroku[web.1]: State changed from starting to crashed
630 2014-06-23T07:13:50.385913+00:00 heroku[web.1]: State changed from crashed to starting
631 2014-06-23T07:13:57.445391+00:00 app[web.1]: [2] Puma starting in cluster mode...
632 2014-06-23T07:13:57.445417+00:00 app[web.1]: [2] * Environment: production
633 2014-06-23T07:13:57.445413+00:00 app[web.1]: [2] * Version 2.8.2 (ruby 2.1.1-p76), codename: Sir Edmund Percival Hillary
634 2014-06-23T07:13:57.445415+00:00 app[web.1]: [2] * Min threads: 1, max threads: 16
635 2014-06-23T07:13:57.445419+00:00 app[web.1]: [2] * Process workers: 4
636 2014-06-23T07:13:57.445423+00:00 app[web.1]: [2] * Preloading application
637 2014-06-23T07:13:54.371058+00:00 heroku[web.1]: Starting process with command `bundle exec puma -C config/puma.rb -p 33243 -e production`
638 2014-06-23T07:13:59.883490+00:00 app[web.1]: /app/vendor/bundle/ruby/2.1.0/gems/puma-2.8.2/lib/puma/binder.rb:195:in `initialize': Address already in use - bind(2) for "0.0.0.0 " port 33243 (Errno::EADDRINUSE)
639 2014-06-23T07:13:59.882892+00:00 app[web.1]: [2] * Listening on tcp://0.0.0.0:33243
640 2014-06-23T07:13:59.883501+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.1.0/gems/puma-2.8.2/lib/puma/binder.rb:96:in `block in parse'
641 2014-06-23T07:13:59.883494+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.1.0/gems/puma-2.8.2/lib/puma/binder.rb:195:in `new'
642 2014-06-23T07:13:59.883499+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.1.0/gems/puma-2.8.2/lib/puma/binder.rb:195:in `add_tcp_listener'
643 2014-06-23T07:13:59.883506+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.1.0/gems/puma-2.8.2/lib/puma/binder.rb:82:in `parse'
644 2014-06-23T07:13:59.883510+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.1.0/gems/puma-2.8.2/lib/puma/runner.rb:119:in `load_and_bind'
645 2014-06-23T07:13:59.883503+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.1.0/gems/puma-2.8.2/lib/puma/binder.rb:82:in `each'
646 2014-06-23T07:13:59.883512+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.1.0/gems/puma-2.8.2/lib/puma/cluster.rb:271:in `run'
647 2014-06-23T07:13:59.883519+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.1.0/bin/puma:23:in `load'
648 2014-06-23T07:13:59.883517+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.1.0/gems/puma-2.8.2/bin/puma:10:in `<top (required)>'
649 2014-06-23T07:13:59.883514+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.1.0/gems/puma-2.8.2/lib/puma/cli.rb:499:in `run'
650 2014-06-23T07:13:59.883525+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.1.0/bin/puma:23:in `<main>'
651 2014-06-23T07:13:59.883273+00:00 app[web.1]: [2] * Listening on tcp://0.0.0.0:33243
652 2014-06-23T07:14:01.451472+00:00 heroku[api]: Set DEV-2-PASS config vars by [email protected]
653 2014-06-23T07:14:01.451540+00:00 heroku[api]: Release v36 created by [email protected]
654 2014-06-23T07:14:01.624035+00:00 heroku[web.1]: State changed from starting to crashed
655 2014-06-23T07:14:01.963688+00:00 heroku[web.1]: State changed from crashed to starting
656 2014-06-23T07:14:01.615855+00:00 heroku[web.1]: Process exited with status 1
danke! Ich habe die Redundanz nicht bemerkt, aber sie löst es immer noch nicht auf Heroku, auch wenn Port und Umgebung nur in prima.rb bleiben. –
Verwenden Sie Ihren alten puma.rb oder den neuen? All dies 'wenn ENV ['RACK_ENV']! = 'Produktion' || ENV ['RAILS_ENV']! = 'Produktion' sollte nicht notwendig sein. Wenn Sie möchten, dass die Anzahl der Worker auf eine Änderung zurückgesetzt wird, klicken Sie auf 'ENV [' PUMA_WORKERS '] || 4 'bis' ENV ['PUMA_WORKERS'] || 1 ' – tmaier
Bitte sehen Sie Updates zu der Frage, ich habe den Grund für bedingte Block und den Status nach der Aktualisierung der Konfigurationen erklärt. –