Starting Your Application At Boot

From OCS Support Wiki

Jump to: navigation, search

[edit] Introduction

While server reboots don't happen often, they unfortunately are necessary from time to time.

[edit] A Note About Editors

Before we start however, it is worth noting that the crontab editor may start Vim. If you are not familiar with Vim you will probably want to use nano instead, which is a modeless and therefore easier to use editor. To have it start instead, make sure and include the EDITOR line in the commands below. If you prefer to use vim, you can set it to vim instead.

[edit] Editing Your Crontab

To ensure your application starts upon boot, in SSH, please run:

export EDITOR=nano
crontab -e

Your crontab file will be presented. This is the list of programs that start at certain times or at boot. Add to it (all on one line):

@reboot cd ~/rails_sites/mysite ; rm -f log/mongrel.pid ; mongrel_rails start -e production -p 60000 -d

Replace rails_sites/mysite with the actual path to your Rails application. Replace 60000 with the port number you were assigned. Save and quit (in nano, this is CTRL+W then CTRL+X, in vim hit ESC then type :wq) and your application will now start upon boot.