Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Setup automatic virtual server provisioning with vagrant and chef

* install and configure vagrant gem
* install and configure librarian gem
* add mongodb-debs cookbook
* add rails-lastmile cookbook
* update README
  • Loading branch information...
commit 2d842019b5b1ad7230a17abe180cb137d2727ab6 1 parent d10b488
@potomak authored
Showing with 617 additions and 5 deletions.
  1. +1 −0  .gitignore
  2. +1 −0  .vagrant
  3. +25 −0 Cheffile
  4. +44 −0 Cheffile.lock
  5. +7 −0 Gemfile
  6. +25 −0 Gemfile.lock
  7. +12 −5 README.md
  8. +106 −0 Vagrantfile
  9. +34 −0 site-cookbooks/mongodb-debs/README.rdoc
  10. +10 −0 site-cookbooks/mongodb-debs/metadata.rb
  11. +35 −0 site-cookbooks/mongodb-debs/recipes/default.rb
  12. +41 −0 site-cookbooks/mongodb-debs/recipes/repo.rb
  13. +2 −0  site-cookbooks/mongodb-debs/templates/debian/mongodb.list.erb
  14. +95 −0 site-cookbooks/mongodb-debs/templates/default/mongodb.conf.erb
  15. 0  site-cookbooks/mongodb-debs/templates/default/mongodb.list.erb
  16. +1 −0  site-cookbooks/mongodb-debs/templates/ubuntu-10.04/mongodb.list.erb
  17. +1 −0  site-cookbooks/mongodb-debs/templates/ubuntu-10.10/mongodb.list.erb
  18. +1 −0  site-cookbooks/mongodb-debs/templates/ubuntu-11.04/mongodb.list.erb
  19. +1 −0  site-cookbooks/mongodb-debs/templates/ubuntu-9.04/mongodb.list.erb
  20. +1 −0  site-cookbooks/mongodb-debs/templates/ubuntu-9.10/mongodb.list.erb
  21. +64 −0 site-cookbooks/rails-lastmile/README.md
  22. +1 −0  site-cookbooks/rails-lastmile/attributes/default.rb
  23. +6 −0 site-cookbooks/rails-lastmile/metadata.rb
  24. +71 −0 site-cookbooks/rails-lastmile/recipes/default.rb
  25. +23 −0 site-cookbooks/rails-lastmile/templates/default/nginx.erb
  26. +9 −0 site-cookbooks/rails-lastmile/templates/default/unicorn.erb
View
1  .gitignore
@@ -7,3 +7,4 @@ config/github.yml
config/twitter.yml
.DS_Store
public/assets
+cookbooks/
View
1  .vagrant
@@ -0,0 +1 @@
+{"active":{"default":"851c4939-651b-499c-b6d9-77d5cd98f848"}}
View
25 Cheffile
@@ -0,0 +1,25 @@
+#!/usr/bin/env ruby
+#^syntax detection
+
+site 'http://community.opscode.com/api/v1'
+
+# cookbook 'chef-client'
+
+# cookbook 'apache2', '>= 1.0.0'
+
+# cookbook 'rvm',
+# :git => 'https://github.com/fnichol/chef-rvm'
+
+# cookbook 'postgresql',
+# :git => 'https://github.com/findsyou/cookbooks',
+# :ref => 'postgresql-improvements'
+
+cookbook 'ruby_build',
+ :git => 'git://github.com/fnichol/chef-ruby_build.git', :ref => 'v0.6.0'
+cookbook 'rbenv',
+ :git => 'https://github.com/fnichol/chef-rbenv', :ref => 'v0.6.4'
+cookbook 'apt',
+ :git => 'https://github.com/fnichol/chef-apt'
+
+cookbook 'nginx'
+cookbook 'vim'
View
44 Cheffile.lock
@@ -0,0 +1,44 @@
+SITE
+ remote: http://community.opscode.com/api/v1
+ specs:
+ bluepill (1.0.6)
+ build-essential (1.1.0)
+ nginx (0.101.6)
+ bluepill (>= 0.0.0)
+ build-essential (>= 0.0.0)
+ ohai (~> 1.0.2)
+ runit (>= 0.0.0)
+ yum (>= 0.0.0)
+ ohai (1.0.2)
+ runit (0.15.0)
+ vim (1.0.2)
+ yum (0.6.2)
+
+GIT
+ remote: git://github.com/fnichol/chef-ruby_build.git
+ ref: v0.6.0
+ sha: f5eae16a199571d15f151f118338b3b11c42f694
+ specs:
+ ruby_build (0.6.0)
+
+GIT
+ remote: https://github.com/fnichol/chef-apt
+ ref: master
+ sha: cb998dfdeffbcbb6805527b046b411206d6c77d6
+ specs:
+ apt (1.2.0)
+
+GIT
+ remote: https://github.com/fnichol/chef-rbenv
+ ref: v0.6.4
+ sha: 4e87a6d477cb6d675eed060e46910cb88d3f4448
+ specs:
+ rbenv (0.6.4)
+
+DEPENDENCIES
+ apt (>= 0)
+ nginx (>= 0)
+ rbenv (>= 0)
+ ruby_build (>= 0)
+ vim (>= 0)
+
View
7 Gemfile
@@ -54,6 +54,9 @@ gem 'omniauth-twitter'
# Thin
gem 'thin'
+# Unicorn
+gem 'unicorn'
+
# New Relic
gem 'newrelic_rpm'
@@ -69,4 +72,8 @@ gem 'merit'
group :development, :test do
gem 'heroku'
gem 'mocha'
+
+ # Virtual box provisioning with vagrant and librarian gems
+ gem 'vagrant'
+ gem 'librarian'
end
View
25 Gemfile.lock
@@ -30,6 +30,7 @@ GEM
multi_json (~> 1.0)
addressable (2.2.7)
ambry (0.3.1)
+ archive-tar-minitar (0.5.2)
arel (3.0.2)
asset_sync (0.4.2)
activemodel
@@ -54,6 +55,8 @@ GEM
multi_json (~> 1.0)
faraday (0.8.1)
multipart-post (~> 1.1)
+ ffi (0.6.3)
+ rake (>= 0.8.7)
fog (1.4.0)
builder
excon (~> 0.14.0)
@@ -86,13 +89,17 @@ GEM
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
railties (>= 3.0.0)
+ kgio (2.7.4)
launchy (2.1.0)
addressable (~> 2.2.6)
+ librarian (0.0.4)
+ thor
libv8 (3.3.10.4)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
+ mario (0.0.6)
merit (0.8.1)
ambry (~> 0.3.0)
metaclass (0.0.1)
@@ -156,6 +163,7 @@ GEM
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
+ raindrops (0.10.0)
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
@@ -187,6 +195,20 @@ GEM
uglifier (1.2.4)
execjs (>= 0.3.0)
multi_json (>= 1.0.2)
+ unicorn (4.3.1)
+ kgio (~> 2.6)
+ rack
+ raindrops (~> 0.7)
+ vagrant (0.5.4)
+ archive-tar-minitar (= 0.5.2)
+ erubis (>= 2.6.6)
+ json (>= 1.4.3)
+ mario (~> 0.0.6)
+ net-scp (>= 1.0.2)
+ net-ssh (>= 2.0.19)
+ virtualbox (~> 0.7.3)
+ virtualbox (0.7.9)
+ ffi (~> 0.6.3)
PLATFORMS
ruby
@@ -199,6 +221,7 @@ DEPENDENCIES
heroku
jquery-rails
kaminari
+ librarian
merit
mocha
mongoid
@@ -211,3 +234,5 @@ DEPENDENCIES
therubyracer
thin
uglifier (>= 1.0.3)
+ unicorn
+ vagrant
View
17 README.md
@@ -6,11 +6,18 @@ Try it for free at [http://tomato.es](http://tomato.es "Tomatoes")
## Why?
-Because
-
-1. the [Pomodoro technique](http://www.pomodorotechnique.com)<sup>®</sup> helps you to get things done;
-2. I need it to measure pomodoros in a fast and easy way;
-3. I want to challenge my friends.
+1. [Pomodoro technique](http://www.pomodorotechnique.com)<sup>®</sup> helps you to get things done.
+1. I need it to measure pomodoros in a fast and easy way.
+1. I want to get motivated by challenging my friends.
+
+## How to setup a development virtual server with Virtualbox
+
+1. Install Virtualbox (see https://www.virtualbox.org/wiki/Downloads).
+1. Fork the project on github and clone the repo.
+1. Run `bundle install` to install required gems.
+1. Run `librarian-chef` to install required cookbooks.
+1. Run `vagrant up` to start a virtual machine containing the app (this process can take a few minutes).
+1. Open http://localhost:8080 on your browser.
## License
View
106 Vagrantfile
@@ -0,0 +1,106 @@
+Vagrant::Config.run do |config|
+ # All Vagrant configuration is done here. The most common configuration
+ # options are documented and commented below. For a complete reference,
+ # please see the online documentation at vagrantup.com.
+
+ # Every Vagrant virtual environment requires a box to build off of.
+ config.vm.box = "lucid32"
+
+ # The url from where the 'config.vm.box' box will be fetched if it
+ # doesn't already exist on the user's system.
+ config.vm.box_url = "http://files.vagrantup.com/lucid32.box"
+
+ # Boot with a GUI so you can see the screen. (Default is headless)
+ # config.vm.boot_mode = :gui
+
+ # Assign this VM to a host-only network IP, allowing you to access it
+ # via the IP. Host-only networks can talk to the host machine as well as
+ # any other machines on the same network, but cannot be accessed (through this
+ # network interface) by any external networks.
+ # config.vm.network :hostonly, "192.168.33.10"
+
+ # Assign this VM to a bridged network, allowing you to connect directly to a
+ # network using the host's network device. This makes the VM appear as another
+ # physical device on your network.
+ # config.vm.network :bridged
+
+ # Forward a port from the guest to the host, which allows for outside
+ # computers to access the VM, whereas host only networking does not.
+ config.vm.forward_port 80, 8080
+
+ # Share an additional folder to the guest VM. The first argument is
+ # an identifier, the second is the path on the guest to mount the
+ # folder, and the third is the path on the host to the actual folder.
+ # config.vm.share_folder "v-data", "/vagrant_data", "../data"
+
+ # Enable provisioning with Puppet stand alone. Puppet manifests
+ # are contained in a directory path relative to this Vagrantfile.
+ # You will need to create the manifests directory and a manifest in
+ # the file base.pp in the manifests_path directory.
+ #
+ # An example Puppet manifest to provision the message of the day:
+ #
+ # # group { "puppet":
+ # # ensure => "present",
+ # # }
+ # #
+ # # File { owner => 0, group => 0, mode => 0644 }
+ # #
+ # # file { '/etc/motd':
+ # # content => "Welcome to your Vagrant-built virtual machine!
+ # # Managed by Puppet.\n"
+ # # }
+ #
+ # config.vm.provision :puppet do |puppet|
+ # puppet.manifests_path = "manifests"
+ # puppet.manifest_file = "base.pp"
+ # end
+
+ # Enable provisioning with chef solo, specifying a cookbooks path, roles
+ # path, and data_bags path (all relative to this Vagrantfile), and adding
+ # some recipes and/or roles.
+
+ config.vm.provision :chef_solo do |chef|
+ chef.cookbooks_path = ["cookbooks", "site-cookbooks"]
+
+ chef.add_recipe "apt"
+ chef.add_recipe "ruby_build"
+ chef.add_recipe "rbenv::system"
+ chef.add_recipe "rbenv::vagrant"
+ chef.add_recipe "nginx"
+ chef.add_recipe "mongodb-debs"
+ chef.add_recipe "rails-lastmile"
+
+ chef.json = {
+ 'rvm' => {
+ 'default_ruby' => 'ruby-1.9.2-p290',
+ 'gem_package' => {
+ 'rvm_string' => 'ruby-1.9.2-p290'
+ }
+ }
+ }
+ end
+
+ # Enable provisioning with chef server, specifying the chef server URL,
+ # and the path to the validation key (relative to this Vagrantfile).
+ #
+ # The Opscode Platform uses HTTPS. Substitute your organization for
+ # ORGNAME in the URL and validation key.
+ #
+ # If you have your own Chef Server, use the appropriate URL, which may be
+ # HTTP instead of HTTPS depending on your configuration. Also change the
+ # validation key to validation.pem.
+ #
+ # config.vm.provision :chef_client do |chef|
+ # chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
+ # chef.validation_key_path = "ORGNAME-validator.pem"
+ # end
+ #
+ # If you're using the Opscode platform, your validator client is
+ # ORGNAME-validator, replacing ORGNAME with your organization name.
+ #
+ # IF you have your own Chef Server, the default validation client name is
+ # chef-validator, unless you changed the configuration.
+ #
+ # chef.validation_client_name = "ORGNAME-validator"
+end
View
34 site-cookbooks/mongodb-debs/README.rdoc
@@ -0,0 +1,34 @@
+= DESCRIPTION:
+
+Installs mongodb from debian pacakges based on the instructions from
+http://www.mongodb.org/display/DOCS/Ubuntu+and+Debian+packages
+
+= REQUIREMENTS:
+
+== Platform:
+
+Tested on Ubuntu 10.04, Debian Lenny.
+
+= USAGE:
+
+Include the mongodb-debs recipe to install mongodb on your system:
+
+ include_recipe "mongodb-debs"
+
+= LICENSE and AUTHOR:
+
+Author:: Marius Ducea (marius@promethost.com)
+
+Copyright:: 2010, Promet Solutions
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
View
10 site-cookbooks/mongodb-debs/metadata.rb
@@ -0,0 +1,10 @@
+maintainer "Promet Solutions"
+maintainer_email "marius@promethost.com"
+license "Apache 2.0"
+description "Installs MongoDB"
+long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc'))
+version "0.2.0"
+
+%w{ ubuntu debian }.each do |os|
+ supports os
+end
View
35 site-cookbooks/mongodb-debs/recipes/default.rb
@@ -0,0 +1,35 @@
+#
+# Author:: Marius Ducea (marius@promethost.com)
+# Cookbook Name:: mongodb
+# Recipe:: default
+#
+# Copyright 2010, Promet Solutions
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+include_recipe "mongodb-debs::repo"
+
+package "mongodb-10gen"
+
+service "mongodb" do
+ action [ :enable, :start ]
+end
+
+template "/etc/mongodb.conf" do
+ source "mongodb.conf.erb"
+ owner "root"
+ group "root"
+ mode 0644
+ notifies :restart, resources(:service => "mongodb")
+end
View
41 site-cookbooks/mongodb-debs/recipes/repo.rb
@@ -0,0 +1,41 @@
+#
+# Author:: Marius Ducea (marius@promethost.com)
+# Cookbook Name:: mongodb
+# Recipe:: repo
+#
+# Copyright 2010, Promet Solutions
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+return unless ["ubuntu", "debian"].include?(node[:platform])
+
+execute "request mongodb key" do
+ command "gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 7F0CEB10"
+ not_if "gpg --list-keys 7F0CEB10"
+end
+
+execute "install mongodb key" do
+ command "gpg -a --export 7F0CEB10 | apt-key add -"
+ not_if "apt-key list | grep 7F0CEB10"
+end
+
+template "/etc/apt/sources.list.d/mongodb.list" do
+ mode 0644
+end
+
+execute "update apt" do
+ command "apt-get update"
+ subscribes :run, resources(:template => "/etc/apt/sources.list.d/mongodb.list"), :immediately
+ action :nothing
+end
View
2  site-cookbooks/mongodb-debs/templates/debian/mongodb.list.erb
@@ -0,0 +1,2 @@
+deb http://downloads-distro.mongodb.org/repo/debian-sysvinit dist 10gen
+
View
95 site-cookbooks/mongodb-debs/templates/default/mongodb.conf.erb
@@ -0,0 +1,95 @@
+# mongodb.conf
+
+# Where to store the data.
+
+# Note: if you run mongodb as a non-root user (recommended) you may
+# need to create and set permissions for this directory manually,
+# e.g., if the parent directory isn't mutable by the mongodb user.
+dbpath=/var/lib/mongodb
+
+#where to log
+logpath=/var/log/mongodb/mongodb.log
+
+logappend=true
+
+#port = 27017
+
+
+
+# Enables periodic logging of CPU utilization and I/O wait
+#cpu = true
+
+# Turn on/off security. Off is currently the default
+#noauth = true
+#auth = true
+
+# Verbose logging output.
+#verbose = true
+
+# Inspect all client data for validity on receipt (useful for
+# developing drivers)
+#objcheck = true
+
+# Enable db quota management
+#quota = true
+
+# Set oplogging level where n is
+# 0=off (default)
+# 1=W
+# 2=R
+# 3=both
+# 7=W+some reads
+#oplog = 0
+
+# Diagnostic/debugging option
+#nocursors = true
+
+# Ignore query hints
+#nohints = true
+
+# Disable the HTTP interface (Defaults to localhost:27018).
+#nohttpinterface = true
+
+# Turns off server-side scripting. This will result in greatly limited
+# functionality
+#noscripting = true
+
+# Turns off table scans. Any query that would do a table scan fails.
+#notablescan = true
+
+# Disable data file preallocation.
+#noprealloc = true
+
+# Specify .ns file size for new databases.
+# nssize = <size>
+
+# Accout token for Mongo monitoring server.
+#mms-token = <token>
+
+# Server name for Mongo monitoring server.
+#mms-name = <server-name>
+
+# Ping interval for Mongo monitoring server.
+#mms-interval = <seconds>
+
+# Replication Options
+
+# in replicated mongo databases, specify here whether this is a slave or master
+#slave = true
+#source = master.example.com
+# Slave only: specify a single database to replicate
+#only = master.example.com
+# or
+#master = true
+#source = slave.example.com
+
+# Address of a server to pair with.
+#pairwith = <server:port>
+# Address of arbiter server.
+#arbiter = <server:port>
+# Automatically resync if slave data is stale
+#autoresync
+# Custom size for replication operation log.
+#oplogSize = <MB>
+# Size limit for in-memory storage of op ids.
+#opIdMem = <bytes>
View
0  site-cookbooks/mongodb-debs/templates/default/mongodb.list.erb
No changes.
View
1  site-cookbooks/mongodb-debs/templates/ubuntu-10.04/mongodb.list.erb
@@ -0,0 +1 @@
+deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen
View
1  site-cookbooks/mongodb-debs/templates/ubuntu-10.10/mongodb.list.erb
@@ -0,0 +1 @@
+deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen
View
1  site-cookbooks/mongodb-debs/templates/ubuntu-11.04/mongodb.list.erb
@@ -0,0 +1 @@
+deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen
View
1  site-cookbooks/mongodb-debs/templates/ubuntu-9.04/mongodb.list.erb
@@ -0,0 +1 @@
+deb http://downloads.mongodb.org/distros/ubuntu 9.4 10gen
View
1  site-cookbooks/mongodb-debs/templates/ubuntu-9.10/mongodb.list.erb
@@ -0,0 +1 @@
+deb http://downloads.mongodb.org/distros/ubuntu 9.10 10gen
View
64 site-cookbooks/rails-lastmile/README.md
@@ -0,0 +1,64 @@
+Description
+===========
+Configures a server for rails hosting. Delegates as much as possible to
+other cookbooks & ties everything together.
+
+Requirements
+============
+Currently requires ruby_build, rb_env, apt, nginx, runit, unicorn
+
+Attributes
+==========
+app_dir location on remote system where rails project will be found.
+Defaults to "/vagrant".
+
+Usage
+=====
+
+Vagrant
+-------
+Vagrant is the first environment rails-lastmile supports. I based my
+build off of the lucid64 base box. In order to use with vagrant make a
+Vagrantfile something like this:
+
+```ruby
+ config.vm.provision :chef_solo do |chef|
+ chef.cookbooks_path = ["cookbooks","cookbooks-src"]
+
+ chef.add_recipe "apt"
+ chef.add_recipe "ruby_build"
+ chef.add_recipe "rbenv::system"
+ chef.add_recipe "rbenv::vagrant"
+ chef.add_recipe "nginx"
+ chef.add_recipe "unicorn"
+ chef.add_recipe "rails-lastmile"
+
+ chef.json = {
+ 'rvm' => {
+ 'default_ruby' => 'ruby-1.9.2-p290',
+ 'gem_package' => {
+ 'rvm_string' => 'ruby-1.9.2-p290'
+ }
+ }
+ }
+
+ end
+```
+
+Installation
+============
+For a more thorough guide visit:
+http://blog.119labs.com/2012/03/rails-vagrant-chef/
+
+I suggest installing through librarian-chef. In order to do so add the
+following to your Cheffile:
+
+```ruby
+cookbook 'rails-lastmile',
+ :git => 'git://github.com/DanThiffault/rails-lastmile.git'
+```
+
+If you're planning on making changes to the lastmile config. I'd suggest
+vendoring the git repo into cookbooks-src
+
+
View
1  site-cookbooks/rails-lastmile/attributes/default.rb
@@ -0,0 +1 @@
+default['rails-lastmile']['app_dir'] = "/vagrant"
View
6 site-cookbooks/rails-lastmile/metadata.rb
@@ -0,0 +1,6 @@
+maintainer "YOUR_COMPANY_NAME"
+maintainer_email "YOUR_EMAIL"
+license "All rights reserved"
+description "Installs/Configures rails-bootstrap"
+long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
+version "0.0.1"
View
71 site-cookbooks/rails-lastmile/recipes/default.rb
@@ -0,0 +1,71 @@
+#
+# Cookbook Name:: rails-bootstrap
+# Recipe:: default
+#
+# Copyright 2012, 119 Labs LLC
+#
+# All rights reserved - Do Not Redistribute
+#
+class Chef::Recipe
+ # mix in recipe helpers
+ include Chef::RubyBuild::RecipeHelpers
+end
+
+app_dir = node['rails-lastmile']['app_dir']
+
+rbenv_ruby "1.9.2-p290"
+rbenv_global "1.9.2-p290"
+
+rbenv_gem "bundler"
+rbenv_gem "rails"
+
+directory "/var/run/unicorn" do
+ owner "root"
+ group "root"
+ mode "777"
+ action :create
+end
+
+file "/var/run/unicorn/master.pid" do
+ owner "root"
+ group "root"
+ mode "666"
+ action :create_if_missing
+end
+
+file "/var/log/unicorn.log" do
+ owner "root"
+ group "root"
+ mode "666"
+ action :create_if_missing
+end
+
+template "/etc/unicorn.cfg" do
+ owner "root"
+ group "root"
+ mode "644"
+ source "unicorn.erb"
+ variables( :app_dir => app_dir)
+end
+
+rbenv_script "run-rails" do
+ rbenv_version "1.9.2-p290"
+ cwd app_dir
+
+ code <<-EOH
+ bundle install
+ bundle exec unicorn -c /etc/unicorn.cfg -D
+ EOH
+end
+
+template "/etc/nginx/sites-enabled/default" do
+ owner "root"
+ group "root"
+ mode "644"
+ source "nginx.erb"
+ variables( :static_root => "#{app_dir}/public")
+ notifies :restart, "service[nginx]"
+end
+
+service "unicorn"
+service "nginx"
View
23 site-cookbooks/rails-lastmile/templates/default/nginx.erb
@@ -0,0 +1,23 @@
+upstream unicorn {
+ server unix:/tmp/unicorn.todo.sock fail_timeout=0;
+}
+
+server {
+ listen 80 default deferred;
+ # server_name example.com;
+ root <%=@static_root %>;
+ try_files $uri/index.html $uri @unicorn;
+ location @unicorn {
+ proxy_set_header X-Forwarded-For
+ $proxy_add_x_forwarded_for;
+ proxy_set_header Host $http_host;
+ proxy_redirect off;
+ proxy_pass http://unicorn;
+ }
+
+ error_page 500 502 503 504 /500.html;
+ client_max_body_size 4G;
+ keepalive_timeout 10;
+}
+
+
View
9 site-cookbooks/rails-lastmile/templates/default/unicorn.erb
@@ -0,0 +1,9 @@
+working_directory "<%=@app_dir%>"
+pid "/var/run/unicorn/master.pid"
+stderr_path "/var/log/unicorn.log"
+stdout_path "/var/log/unicorn.log"
+
+listen "/tmp/unicorn.todo.sock"
+worker_processes 2
+timeout 30
+
Please sign in to comment.
Something went wrong with that request. Please try again.