I recently set up a Ruby on Rails Droplet and I added Bootstrap to it so it would look nice. Then I was trying to add esbuild as the javascript bundler. I don’t know what the default one is. I kept getting errors whenever I tried to install it. I would comment out one thing and other errors would appear. I decided to just create a new Rails project with esbuild and bootstrap added by default. Normally I use “rails server” to run it but the droplet uses systemctl or whatever to make it so the server is always running in the background and I can do other things while it’s running (which is pretty cool). If someone could help me figure out how to install/add esbuild or set up the systemctl thing so I can run my new project that would be very helpful. I don’t know if I can edit this after I submit it or if I should include the errors that I’m getting now.
I would like to have it where the server is running in the background so I can do other things as well. How would I configure systemctl to do that?
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!
Heya,
As of Rails 7, it uses esbuild as its default JavaScript bundler. If you’re using an older version of Rails, you can add esbuild by adding the esbuild-rails gem to your Gemfile. Then, run bundle install.
Here is a basic setup:
gem 'esbuild-rails' to your Gemfile.bundle install to install the new gem../bin/esbuild in your terminal to check if esbuild is correctly set up.javascript_pack_tag with javascript_esbuild_tag in your views.Systemd is a system and service manager for Linux. You can use it to keep your Rails server running in the background, automatically start it at boot, and restart it if it crashes.
Here’s a basic example of how you can create a systemd service for your Rails app:
Create a new service file. Replace myapp with your application’s name:
- sudo nano /etc/systemd/system/myapp.service
Add the following content to the file. Replace /path/to/your/app with the path to your Rails application and myapp with your application’s name:
[Unit]
Description=My Rails App
After=network.target
[Service]
Type=simple
User=youruser
WorkingDirectory=/path/to/your/app
ExecStart=/usr/local/bin/bundle exec rails s -b 0.0.0.0
Restart=always
[Install]
WantedBy=multi-user.target
Save and close the file.
Enable the service so it starts at boot:
sudo systemctl enable myapp
Start the service:
sudo systemctl start myapp
You can check the status of your service at any time with systemctl status myapp.
This setup assumes you have installed Ruby, Rails, and Bundler system-wide. If you’re using a version manager like rbenv or rvm, you’ll need to adjust the ExecStart line to source the correct Ruby version.
These steps should get you started. However, there could be other factors causing the issues you’re seeing, and without the specific error messages, it’s difficult to provide a more accurate solution. If these steps don’t resolve your issues, it might be helpful to post the exact errors you’re getting.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.