Spin up a stack for development that is similar to what might be used in production.
Right now the stack consists of:
- NGINX 1.4.7
- Haproxy 1.4.24
- PostgreSQL 9.3
- Ruby 2.1 (via rbenv & ruby-build)
- Rails 4.1
- OS X 10.9.2
- Vagrant 1.5.2
- Ansible 1.5 (master 29110c31ea)
- Vagrant
- Ansible
- VMWare Fusion - Could be altered for VirtualBox
- VMWare Fusion Plugin for Vagrant.
Clone the repository into a directory where you want to keep your project files. I place it in ~/src
.
Edit /etc/hosts
on your local development machine:
192.168.2.10 haproxy.dev
192.168.2.10 rails-test.dev
vagrant up app_ruby_1 --provider=vmware_fusion
vagrant up app_ruby_2 --provider=vmware_fusion
vagrant up postgres --provider=vmware_fusion
vagrant up haproxy --provider=vmware_fusion
vagrant up web --provider=vmware_fusion
You should let both of the app servers finish starting up before starting HAproxy, as it will need to pull information from them.
vagrant ssh app_ruby_1
$ cd /srv/www/
$ rails new rails_test
default: &default
adapter: postgresql
pool: 5
timeout: 5000
development:
<<: *default
host: 192.168.2.30
port: 5432
database: test
username: tester
password: insecure
vagrant ssh app_ruby_1
$ cd /srv/www/rails_test
$ rails s -d
$ exit
And...
vagrant ssh app_ruby_2
$ cd /srv/www/rails_test
$ rails s -d
$ exit
- 192.168.2.10
- Listening on port 80
- At the moment, all requests sent on to HAProxy
- 192.168.2.20
- Listening on port 80 & 8080
- Port 80 services HAProxy's stats UI
- Port 8080 is balanced out to the 2 app servers.
- 192.168.2.30
- Listening on port 5432
- Will accept requests from app servers (configured in pg_hba.conf)
- 192.168.2.100 & 192.168.2.101
- Webrick listens on port 3000