Skip to content

Commit

Permalink
Starting move over to capistrano.
Browse files Browse the repository at this point in the history
  • Loading branch information
russ committed Jan 16, 2013
1 parent 7901cdd commit 6754005
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 31 deletions.
4 changes: 4 additions & 0 deletions Capfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
load 'deploy'
# Uncomment if you are using Rails' asset pipeline
# load 'deploy/assets'
load 'config/deploy' # remove this line to skip loading any of the default tasks
29 changes: 4 additions & 25 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ source :rubygems

gem 'rails', '3.2.11' #need to wait until rails 3.2.8 - https://github.com/rspec/rspec-rails/issues/577

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'rake', '10.0.3'
gem 'sqlite3'
gem 'omniauth-twitter'
Expand All @@ -22,33 +19,14 @@ gem 'sinatra', require: false
gem 'slim'
gem 'turbolinks'

# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# To use Jbuilder templates for JSON
# gem 'jbuilder'

# Use unicorn as the app server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'

def darwin_only(require_as)
RUBY_PLATFORM.include?('darwin') && require_as
end
Expand All @@ -58,22 +36,23 @@ def linux_only(require_as)
end

group :development do
gem "rspec-rails"
gem "rspec-rails"
gem "guard-rspec"
gem "guard-spork"
gem "sqlite3"
gem 'capistrano-unicorn', git: 'git://github.com/sosedoff/capistrano-unicorn.git'

# mac
gem "rb-fsevent", require: darwin_only('rb-fsevent')
gem "growl", require: darwin_only('growl')

# linux
gem 'rb-inotify', require: linux_only('rb-inotify')
gem 'libnotify', require: linux_only('libnotify')
gem 'git-deploy'
end

group :test do
gem "rspec-rails"
gem "rspec-rails"
gem "factory_girl_rails"
gem "database_cleaner"
gem "capybara"
Expand Down
26 changes: 20 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
GIT
remote: git://github.com/sosedoff/capistrano-unicorn.git
revision: 6f7a4879d3db41644e7403b20d9410f575cfc33a
specs:
capistrano-unicorn (0.1.6)
capistrano

GEM
remote: http://rubygems.org/
specs:
Expand Down Expand Up @@ -33,6 +40,12 @@ GEM
bootstrap-will_paginate (0.0.9)
will_paginate
builder (3.0.4)
capistrano (2.14.1)
highline
net-scp (>= 1.0.0)
net-sftp (>= 2.0.0)
net-ssh (>= 2.0.14)
net-ssh-gateway (>= 1.1.0)
capybara (2.0.2)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
Expand Down Expand Up @@ -73,10 +86,6 @@ GEM
ffi (1.2.0)
foreman (0.60.2)
thor (>= 0.13.6)
git-deploy (0.5.4)
net-scp
net-ssh
thor
growl (1.0.3)
guard (1.6.1)
listen (>= 0.6.0)
Expand All @@ -91,6 +100,7 @@ GEM
guard (>= 1.1)
spork (>= 0.8.4)
hashie (1.2.0)
highline (1.6.15)
hike (1.2.1)
http_parser.rb (0.5.3)
i18n (0.6.1)
Expand Down Expand Up @@ -124,7 +134,11 @@ GEM
mysql2 (0.3.11)
net-scp (1.0.4)
net-ssh (>= 1.99.1)
net-ssh (2.6.2)
net-sftp (2.0.5)
net-ssh (>= 2.0.9)
net-ssh (2.6.3)
net-ssh-gateway (1.1.0)
net-ssh (>= 1.99.1)
nokogiri (1.5.6)
oauth (0.4.7)
omniauth (1.1.1)
Expand Down Expand Up @@ -273,12 +287,12 @@ PLATFORMS

DEPENDENCIES
bootstrap-will_paginate
capistrano-unicorn!
capybara
coffee-rails (~> 3.2.1)
database_cleaner
factory_girl_rails
foreman
git-deploy
growl
guard-rspec
guard-spork
Expand Down
34 changes: 34 additions & 0 deletions config/deploy.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

set :application, 'bulletin_board'
set :repository, 'git://github.com/LasVegasRubyGroup/vegastech_app.git'

set :scm, 'git'
set :scm_verbose, true
set :branch, 'master'
set :user, 'lvrug'
set :group, 'lvrug'
set :deploy_via, 'remote_cache'
set :deploy_to, "/home/#{user}/applications/#{application}"
set :use_sudo, false
set :init_script, "/etc/init.d/#{application}"

role :web, '66.209.73.11'
role :app, '66.209.73.11'
role :db, '66.209.73.11', primary: true

require 'capistrano-unicorn'

after 'deploy:restart', 'deploy:cleanup'
after 'deploy:restart', 'unicorn:restart'

# if you're still using the script/reaper helper you will need
# these http://github.com/rails/irs_process_scripts

# If you are using Passenger mod_rails uncomment this:
# namespace :deploy do
# task :start do ; end
# task :stop do ; end
# task :restart, :roles => :app, :except => { :no_release => true } do
# run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
# end
# end
2 changes: 2 additions & 0 deletions config/unicorn.rb → config/unicorn/development.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'capistrano-unicorn'

rails_env = ENV['RAILS_ENV'] || 'production'
root_path = File.expand_path(File.dirname(__FILE__) + '/../')

Expand Down
38 changes: 38 additions & 0 deletions config/unicorn/production.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
require 'capistrano-unicorn'

rails_env = ENV['RAILS_ENV'] || 'production'
root_path = File.expand_path(File.dirname(__FILE__) + '/../')

worker_processes 1
timeout 30
preload_app true

pid "#{root_path}/tmp/pids/unicorn.pid"

listen "#{root_path}/tmp/sockets/unicorn.sock", backlog: 2048

stderr_path "#{root_path}/log/unicorn.stderr.log"
stdout_path "#{root_path}/log/unicorn.stdout.log"

before_fork do |server, worker|
if defined?(ActiveRecord::Base)
ActiveRecord::Base.connection.disconnect!
Rails.logger.info('Disconnected from ActiveRecord')
end

old_pid = "#{root_path}/tmp/pids/unicorn.pid.oldbin"
if File.exists?(old_pid) && server.pid != old_pid
begin
Process.kill('QUIT', File.read(old_pid).to_i)
rescue Errno::ENOENT, Errno::ESRCH
# someone else did our job for us
end
end
end

after_fork do |server, worker|
if defined?(ActiveRecord::Base)
ActiveRecord::Base.establish_connection
Rails.logger.info('Connected to ActiveRecord')
end
end

0 comments on commit 6754005

Please sign in to comment.