ruby - Error deploying rails app on puma in Heroku -
i trying deploy rails app running on puma , jruby. procfile follows
web: bundle exec puma -c config/puma.rb -p $port -e $rack_env configuration puma placed 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 # worker specific setup activesupport.on_load(:active_record) 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 the reason have conditional initialisation workers because heroku complains (or may puma) worker mode not available jruby , windows; anyway,
the unusual behaviour notice on heroku (unlike) local environment clustered puma instance starts without problems, , picks 2 different ports bind i.e. 3000 , 5000.
however, on production i.e. heroku causes crash
2014-06-23t08:50:54.545724+00:00 heroku[web.1]: state changed crashed starting 2014-06-23t08:51:02.510184+00:00 app[web.1]: picked java_tool_options: -djava.rmi.server.usecodebaseonly=true 2014-06-23t08:51:01.333763+00:00 heroku[web.1]: starting process command `bundle exec puma -c config/puma.rb -p 49576 -e production` 2014-06-23t08:51:21.658663+00:00 app[web.1]: picked 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]: signal usr1 in utilize jvm , not work correctly on 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 in utilize - bind - address in utilize 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 @ org/jruby/ext/socket/rubytcpserver.java:118 2014-06-23t08:51:57.852478+00:00 app[web.1]: add_tcp_listener @ /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 @ 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 @ /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 @ org/jruby/rubyarray.java:1613 2014-06-23t08:51:57.852482+00:00 app[web.1]: parse @ /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 @ /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 @ /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 @ /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) @ /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 @ org/jruby/rubykernel.java:1099 2014-06-23t08:51:57.852492+00:00 app[web.1]: (root) @ /app/vendor/bundle/jruby/1.9/bin/puma:23 2014-06-23t08:51:59.347012+00:00 heroku[web.1]: state changed starting crashed 2014-06-23t08:51:59.333790+00:00 heroku[web.1]: process exited status 1 this unusual startup behaviour not seen when run on laptop.
the way have got puma working on jruby in heroku through setting
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 # worker specific setup activesupport.on_load(:active_record) 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 i.e. if port , environment directives out side if block heroku somehow tried run 2 instances on same port, cause crash.
am missing configuration here or running in clustered mode (i tried running on ruby 2.0.0 instead of jruby) not possible 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 # worker specific setup activesupport.on_load(:active_record) 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 the reason conditional block (quoted initial problem description
the reason have conditional initialisation workers because heroku complains (or may puma) worker mode not available jruby , windows;
and error logs (even if remove jruby, conditional worker block) , seek run on clustered mode
606 2014-06-23t07:13:42.058507+00:00 heroku[api]: release v35 created foo@bar.com 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 in utilize - bind(2) "0.0.0.0 " port 45245 (errno::eaddrinuse) 615 2014-06-23t07:13:49.078775+00:00 app[web.1]: /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]: /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]: /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]: /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]: /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]: /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]: /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]: /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]: /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]: /app/vendor/bundle/ruby/2.1.0/bin/puma:23:in `load' 625 2014-06-23t07:13:49.078801+00:00 app[web.1]: /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 status 1 628 2014-06-23t07:13:45.838792+00:00 heroku[web.1]: starting process 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 starting crashed 630 2014-06-23t07:13:50.385913+00:00 heroku[web.1]: state changed crashed 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 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 in utilize - bind(2) "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]: /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]: /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]: /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]: /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]: /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]: /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]: /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]: /app/vendor/bundle/ruby/2.1.0/bin/puma:23:in `load' 648 2014-06-23t07:13:59.883517+00:00 app[web.1]: /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]: /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]: /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 foo@bar.com 653 2014-06-23t07:14:01.451540+00:00 heroku[api]: release v36 created foo@bar.com 654 2014-06-23t07:14:01.624035+00:00 heroku[web.1]: state changed starting crashed 655 2014-06-23t07:14:01.963688+00:00 heroku[web.1]: state changed crashed starting 656 2014-06-23t07:14:01.615855+00:00 heroku[web.1]: process exited status 1
i had right same issue you.
it seems related duplicate definition of port
first in procfile , later in config/puma.rb file
i removed port procfile (as environment), defined in config/puma.rb.
web: bundle exec puma -c config/puma.rb ruby heroku ruby-on-rails-4 puma
No comments:
Post a Comment