Ruby on Rails One Click install - Change/add application and keep Puma running

Posted October 18, 2018 6.1k views
Ruby on RailsUbuntu 18.04

Good day,

I’ve use the one click Ruby on Rails image to create a droplet. I’ve cloned my project in /home/rails/project-name and installed all dependancies and migrated the database. I’ve also created a virtual host configuration file in sites-available and added a symbolic link to sites enabled.

I’ve edited /etc/systemd/system/rails.service to changed the path. I’ve reloaded/refreshed the unit file and restarted the rails service and rebooted the server.

The problem I have is that my application won’t work unless I start puma manually (if I don’t nginx shows a 502 error).

If I start the puma server manually everything works fine but it shuts down as soon as I exit the terminal.

Please can someone help me figure out what the issue might be? This happens when both I listen on port 3000 and using a unix socket. It even happens for a fresh rails installation. The only difference in my app and the example app is that I use MySql instead of Postgres…

Any ideas?


These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
5 answers

Try seeing the output of

tail -f /var/log/syslog 

Take a look if it shows: “ Environment: development”… somewhere in the Puma output.

I was able to add any Environment Variable I needed in the file:
using the format

Environment="One=1" "Three=3"

I achieved removal the 5XX Server Error after affected services were restarted and systemctl daemon-reload used. So add-to-that:
systemctl restart nginx
systemctl restart rails
(…if not a full reboot).

In actuality, mine config turned out to be more like:

Environment="RAILS_MASTER_KEY=blah1234" #This is a Rails >v5.2 feature

Some more thoughts:
A point of consumption for me is confusing ENV Vars, particularly if whether they are being set, or benignly stored in /root/.passwords.digitalocean.or.something

The /root/.dot-file location seems to indeed be benign, (but also a good place to copy the above-needed environment variables from.)

I will research if there is a more appropriate place for these environment settings I describe in this post. So, if you have info, please share.


  • Thanks, @paccha!

    Busy writing another app now and I managed to get it working by setting Environment="RAILS_ENV=production" in /etc/systemd/system/rails.service.

    Now my assets can’t be found in production so I’ve added the following to my `config/environments/production.rb file:

    config.assets.compile = true
    config.assets.digest = true

    This allows the app to fallback to the asset pipeline if a precompiled asset is missed (I think). Then I need to restart nginx and the rails systemd service as root. Still trying to see what is the best way to get Capistrano to restart these…


I’m facing the same issue with my server (same config as yours). While I haven’t found any solutions yet, I noticed that their original setup does not work either. When you create a new droplet and try accessing the url (droplet’s IP), it shows a NGINX page, not at all a Rails page. Also, if you take a look at their /home/rails/example app, it’s just an empty shell, there’s not even a view to be render. With Puma, NGINX should normally implement an upstream which is not present in /etc/nginx/sites-enabled/rails.

Is there a member of Digitalocean team that could help us understand this ? What’s the point of a one-click app if the setup is not working properly ? Not blaming you guys (you are doing an amazing work), just trying to understand.

I’ll keep you posted if I found any clues, will try to set this up as if the server was a fresh install without Rails/Ruby/Puma.

I’ve ran into the same roadblock. I get 502 bad gateway and I can’t seem to get Puma to serve the app (even if I run it from the terminal and keep it running there). Any luck anyone, or @digitalocean ?

Thank you,

I have the same problem. Please, @digitalocean give us a solution.

Hell, did anyone find a solution this problem?