Start Rails Server Automatically When Ever I Start My Ubuntu MAChine

Start rails server automatically when ever I start my ubuntu machine

You can use a cron job for this. To add the cron job use the command crontab -e. Than you can define a cron job that runs at boot and reboot with @reboot command.

So you'd have something like:

@reboot cd /home/[path to project] && rails server

start thinking sphinx on rails server startup

There's two options I can think of.

  • You could look at how Ubuntu manages start-up scripts and add one for this (perhaps in /etc/init?).
  • You could set up monit or another monitoring tool and have it keep Sphinx running. Monit should boot automatically when your server restarts, and so it should ensure Sphinx (and anything else it's tracking) is running.

The catch with Monit and other such tools is that when you deliberately stop Sphinx (say, to update configuration structure and corresponding index changes), it might start it up again before it's appropriate. So I think you should start with the first of these two options - I just don't know a great deal about the finer points of that approach.

start unicorn app server when the ubuntu server starts

In my case, I just wanted it quick so I place the startup command in /etc/rc.local like below. Note that i'm using RVM.

# By default this script does nothing.
cd <your project dir>
/usr/local/rvm/gems/ruby-2.2.1/wrappers/bundle exec unicorn -c <your project dir>/config/unicorn.conf -D
test -e /etc/ssh/ssh_host_dsa_key || dpkg-reconfigure openssh-server
exit 0

Make sure your startup command is above the exit 0. After you reboot, check whether it is running or not by directly hitting the url of your application or use ps -aux | grep unicorn command.

Note* Previously I use Phusion Passenger but I'm having trouble to see its error log, so I move back to unicorn. I also tried @warantesbr without success, which I guess it fails because my whole environment where setup using root access.

Starting Resque at boot / Passenger restart

What about using foreman for this issue?

Foreman is a procfile-based tool to manage multi-process rails apps.

A simple intro can be seen at railscasts. An example may look like this:

web: bundle exec rails server
solr: bundle exec rake sunspot:solr:run
resque: rake RAILS_ENV=production environment resque:work QUEUE='*'


Related Topics



Leave a reply



Submit