Search code examples
ruby-on-railsrubyraspberry-piraspbianactivesupport

start rails server after raspberry reboots


I want my raspberry pi to start a rails server everytime it reboots. I can start the server without any problems using "rails server". To start the server after the raspberry pi reboots I put the command in the rc.local file. Using this will cause an error saying that i should run bundle install due to missing gems. If I try to use bundle install it will cause another error message saying "active support '5.0.2' is missing use gem install -v'5.0.2' ".

Using the command will print the message that activesupport is sucessfully installed but if I use bundle install again the error message is still showing up.

But all the error messages are not showing up if I use rails server myself.


Solution

  • It's because rc.local runs commands a root user instead of your normal user.

    You should use: su YOUR_USER_NAME -c 'rails server'