I have an EBS app using Ruby and Puma, in my rails app, I have puma.rb in /config/puma.rb as:
workers 2
threads 1, 6
app_dir = File.expand_path("../..", __FILE__)
# Default to production
rails_env = ENV['RAILS_ENV'] || "production"
environment rails_env
activate_control_app
# Allow puma to be restarted by `rails restart` command.
plugin :tmp_restart
and I have puma gem listed in Gemfile and installed
when I deploy to elastic beanstalk app, I get a successful deployment, and the app state is green, however, when I visit the app link, I get error This site can’t be reached
I tried to ssh into the ec2 instance, puma command will get:
$ puma
Puma starting in single mode...
* Version 2.16.0 (ruby 2.5.1-p57), codename: Midwinter Nights Trance
* Min threads: 0, max threads: 16
* Environment: production
ERROR: No application configured, nothing to run
so, what do I miss?
Related
I'm trying to run a Rails 6 app on AWS Elastic Beanstalk, but I get from puma log the following (repeats every few seconds)
[21776] + Gemfile in context: /var/app/current/Gemfile
[21776] Early termination of worker
The version numbers:
Rails 6.0.3.3
puma 4.3.5
ElasticBeanstalk Ruby 2.7 running on 64bit Amazon Linux 2/3.1.1
ruby 2.7.1p83
The server is unresponsive from outside the instance, and there's nothing on log/production.log.
Running on a dev machine on production mode there's no errors, and the database is reachable (no migration failure).
Running on the AWS instance the command bundle exec puma -p 3000 -e production I get
Puma starting in single mode...
Version 4.3.5 (ruby 2.7.1-p83), codename: Mysterious Traveller
Min threads: 5, max threads: 5
Environment: production
Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop
so there's no obvious error that may cause the worker to halt.
How can I find out what's causing the workers to fail?
Edit 1:
I ran Rails console on the instance and found that the environment variables are missing - e.g. the production database user/pass/host. Once I hardcoded them I could connect to the database.
I suspect the absence of other environment variables is making the app crash.
A user on AWS forum had the answer.
Setting in my Gemfile
gem "nio4r", "= 2.5.2"
fixed the issue.
Specs: Rails 4.2.4, Ruby 2.1.9, running puma, EC2 instance in production mode
I have an SSL certificate that I want to install on my server but using techniques like this one yields no results
rails s puma -b 'ssl://0.0.0.0:9292?key=path_to_key.key&cert=path_to_cert.crt&verify_mode=none&ca=path_to_root_bundle.crt'
How to configure Rails with Puma to use SSL?
also
RAILS_ENV=production rvmsudo -E rails s puma -b "ssl://0.0.0.0:9292?key=${KEY_PATH}&cert=${CERT_PATH}&verify_mode=peer&ca=${CERT_BUNDLE_PATH}" -p 80
Instead of a functioning server I get
Puma starting in single mode...
* Version 3.2.0 (ruby 2.1.9-p490), codename: Spring Is A Heliocentric Viewpoint
* Min threads: 0, max threads: 16
* Environment: production
* Listening on tcp://ssl://0.0.0.0:9292?key=~/evslideshow.key&cert=~/e3b162f57ea48f91.crt&verify_mode=peer&ca=~/gd_bundle-g2-g1.crt:80
Exiting
> /home/ec2-user/.rvm/gems/ruby-2.1.9#slideshow/gems/puma-3.2.0/lib/puma/binder.rb:240:in
`initialize': getaddrinfo: Name or service not known (SocketError)
Now my mind is playing with different options. Am I just missing some fundamental aspect of using puma here? The puma documentation is very scared which is why I'm asking here. Or I could use Nginx because it seems like there is alot of documentation on the internets on setting that up with SSL certificate.
If there is a simpler fix for puma then I will just use that.
Found the solution by reading through some of the issue pages on puma's Github page. Apparently we must call puma directly, and not through rails server, despite what was said here in this old stackoverflow answer
The working code is
RAILS_ENV=production rvmsudo -E puma -d -b "ssl://0.0.0.0:443?key=${KEY_PATH}&
cert=${CERT_PATH}&verify_mode=peer&ca=${CERT_BUNDLE_PATH}" -p 80
Make sure to turn on config.force_ssl in your production config file as well.
I just set up Puma and it's working fine as a development server.
When I run an integration test, Puma is starting in development mode, not test mode.
Gemfile
group :test do
gem puma
end
test/test_helper.rb
class ActionDispatch::IntegrationTest
require 'rack/handler/puma'
Capybara.server = :puma
Capybara.register_server("puma") do |app, port|
server = Puma::Server.new(app)
server.add_tcp_listener(Capybara.server_host, port)
server.run
end
end
A test:
✗ RAILS_ENV="test" ruby -I test test/integration/computers_test.rb -n /polt/
Started with run options -n /polt/ --seed 3050
Puma starting in single mode...
* Version 3.8.2 (ruby 2.3.1-p112), codename: Sassy Salamander
* Min threads: 0, max threads: 4
* Environment: development
* Listening on tcp://127.0.0.1:49875
Use Ctrl-C to stop
...
Does the same behavior happen when you run rake test ?
I'd make sure in your config/puma.rb file (create one if you don't have one ) you have a line like environment ENV.fetch("RAILS_ENV") { "development" } - without it I was seeing the same behavior you were.
You need to set the RACK_ENV as the RAILS_ENV to :
RACK_ENV="test" RAILS_ENV="test" ruby -I test test/integration/computers_test.rb -n /polt/
Then the puma server will use the test environment:
* Min threads: 0, max threads: 4
* Environment: test
* Listening on tcp://127.0.0.1:49875
Add
ENV["RAILS_ENV"] = "test"
ENV["RACK_ENV"] = "test"
in your test file, before all tests.
This is actually similar to #ZedTuX answer, but I cannot comment there.
Hi I am trying to deploy RoR app using puma as application server and Nginx. Iam following tutoril available here:
http://codeonhill.com/rails-capistrano-puma-nginx-on-vps/
Sorry Being a newbie in deployment, I want to ask whether we can deploy Rails app using Nginx as reverse proxy on local machine?
Secondly after wasting an entire day i could able to deploy it sucessfully
user#username-VirtualBox:~/Rails/rails-nginx-passenger-ubuntu/testapp$ bundle exec puma -b unix://tmp/testapp.sock
Puma starting in single mode...
* Version 3.8.2 (ruby 2.3.1-p112), codename: Sassy Salamander
* Min threads: 0, max threads: 16
* Environment: development
* Listening on unix://tmp/testapp.sock
* Starting control server on unix:///tmp/puma-status-1490292608378-29275
Use Ctrl-C to stop
And when i am trying to access this url iam getting google search result. How to access my application over there?
I am working on a project which is an updated version of a new project. Using vagrant to load virtual environment and when i run
RAILS_ENV=development bundle exec rails s
The following is returned:
=> Booting Puma
=> Rails 5.0.0.1 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.6.0 (ruby 2.3.3-p222), codename: Sleepy Sunday Serenity
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://localhost:3000
Use Ctrl-C to stop
When i visit the browser I have tried localhost:3000 and 127.0.0.1:3000 but keep getting:
ERR_CONNECTION_REFUSED
On the previous version of this project on a different repository loaded it was accessible via these URL's. This project has been updated to Rails 5 but dont know why it is listening on TCP rather than HTTP. Any suggestions?
As it has been already suggested, make sure that the server is bounden to 0.0.0.0 so that all interfaces can access it.
You might try:
RAILS_ENV=development bundle exec rails s -b 0.0.0.0