Install production - npolar/api.npolar.no GitHub Wiki

Overview

  • Use nginx + Unicorn
  • Use a read-only git clone git://github.com/npolar/api.npolar.no.git
  • Use a dedicated api user
  • Use bundle install --binstubs
  • Create a wrapper for unicorn that points to the user based Ruby install
  • Create a init.d script and make sure that the API starts on reboot
  • Remove sudo from api user after install
  • Add nginx user to api/datacenter group
  • Make sure group has execution rights

Links

Quickstart

sudo useradd -m -G users,sudo -s /bin/bash api
sudo su - api && cd ~

# ruby / rvm @todo
# install rvm: curl -sSL https://get.rvm.io | bash -s stable
# update rvm:rvm get head
rvm install 2.1
rvm use 2.1 --default
git clone git://github.com/npolar/api.npolar.no.git
# update git pull of course
bundle install --binstubs


# The alias points to the Ruby you want to use. On Ruby update alias needs to be updated as well
rvm alias create api ruby-2.3.1 
rvm wrapper default unicorn
 # Generates a unicorn wrapper with env at /home/api/.rvm/wrappers/api/unicorn

sudo cp ~/api.npolar.no/example/install/etc/init.d/api.npolar.no /etc/init.d/

Now root can control the API Unicorn service manually.

The following starts the API (served by Unicorn) on port 9000

sudo service api.npolar.no start

For automatic startup on boot, do

sudo update-rc.d api.npolar.no defaults

(On CentOS: chkconfig --add api.npolar.no)

Restart the API on Unicorn without affecting other services you run on nginx

# service api.npolar.no restart

Logrotate

To setup log rotation you need to copy the file under api.npolar.no/example/install/logrotate to the /etc/logrotate.d folder.

sudo cp ~/api.npolar.no/example/install/logrotate/api.npolar /etc/logrotate.d/

(make sure to check if the log path in the logrotate file matches that of your install)

See alse: Install