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!
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.
Enter your email to get $200 in credit for your first 60 days with DigitalOcean.
New accounts only. By submitting your email you agree to our Privacy Policy.
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 theesbuild-rails
gem to yourGemfile
. Then, runbundle 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
withjavascript_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:Add the following content to the file. Replace
/path/to/your/app
with the path to your Rails application andmyapp
with your application’s name:Save and close the file.
Enable the service so it starts at boot:
Start the service:
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.