0
votes

I am able to start Puma using this command: $HOME/.rbenv/bin/rbenv exec bundle exec puma -C /home/deploy/tasks/shared/puma.rb --daemon -p 3000 And the app is working serving all pages. I do not have Nginx or Apache installed yet. I am trying to have first and Upstart Puma script developed first. Running the command:

$ sudo start puma-manager
puma-manager start/running

gives me the impression that everything is ok while in reality the command

$ ps -ef | grep puma

returns nothing. Digging more into the log file

$ sudo tail -f /var/log/upstart/puma-_home_deploy_tasks_current.log

I am getting an error like this:

[2889] Puma starting in cluster mode...
[2889] * Version 3.6.0 (ruby 2.3.1-p112), codename: Sleepy Sunday Serenity
[2889] * Min threads: 5, max threads: 5
[2889] * Environment: development
[2889] * Process workers: 2
[2889] * Preloading application
[2889] ! Unable to load application: LoadError: Could not load the 'listen' gem. Add `gem 'listen'` to the development group of your Gemfile
bundler: failed to load command: puma (/home/deploy/tasks/shared/bundle/ruby/2.3.0/bin/puma)
LoadError: Could not load the 'listen' gem. Add `gem 'listen'` to the development group of your Gemfile
  /home/deploy/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
  /home/deploy/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `block in require'
  /home/deploy/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
  /home/deploy/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'

Don't know how to fix this and move forward with the Puma settings?

1

1 Answers

1
votes

I scrapped the AWS EC2 instance and recreate it using and Ubuntu 14.04 implementation which I upgraded to 16.04. I followed strictly the guidance found here

http://codepany.com/blog/rails-5-puma-capistrano-nginx-jungle-upstart/

and related links from the same blog.

Now Nginx and Puma are working properly together and my app runs perfectly here:

http://ec2-54-159-156-217.compute-1.amazonaws.com/

The only difference form the guidelines is that I kept the AWS RDS instance for the database. I used RVM in the production server although I am using RBENV on my Mac. I used ubuntu user (like root) for deployment since I am suspecting all the troubles I had were related to permissions and I did not know how to fix them.

Many errors encountered earlier trying to start properly Puma on socket and make it working with Nginx, especially not restarting after

cap production deploy

were related to generating the secret and putting this value in the appropiate file. For me it worked the best writing it in the /etc/environment file.

I also did changes in the file /etc/ssh/sshd_config in order to get root or ubuntu access through ssh. In this matter this link

https://forums.aws.amazon.com/thread.jspa?threadID=86876

was very useful.