Question

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

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?

Show comments

Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Accepted Answer

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: /etc/systemd/system/rails.service using the format

[Service]
Type=simple
Environment="One=1" "Three=3"
Environment="Two=2"
Environment="Four=4"

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_ENV=production"
Environment="RAILS_MASTER_KEY=blah1234" #This is a Rails >v5.2 feature
Environment="RAILS_DATABASE_PASSWORD=12341234etc..."

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.

referenced: https://unix.stackexchange.com/questions/455261/how-to-set-environmental-variable-in-systemd-service

https://www.digitalocean.com/docs/one-clicks/ruby-on-rails/

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,

Hi,

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.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel