Skip to content

Commit

Permalink
Add more common tasks to capistrano.rb; add tasks for niet & apache
Browse files Browse the repository at this point in the history
  • Loading branch information
Shevaun Coker committed May 29, 2012
1 parent c0a5a77 commit 29f17af
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 9 deletions.
4 changes: 2 additions & 2 deletions easy-deployment.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ Gem::Specification.new do |gem|
gem.name = "easy-deployment"
gem.require_paths = ["lib"]
gem.version = Easy::Deployment::VERSION


gem.add_runtime_dependency 'rails', '>= 3.0.0'
gem.add_runtime_dependency 'capistrano'
gem.add_runtime_dependency 'capistrano-ext'
gem.add_runtime_dependency 'capistrano_colors'

gem.add_development_dependency 'bundler'
gem.add_development_dependency 'rspec', '~> 2.8'
gem.add_development_dependency 'rspec', '~> 2.0'
end
2 changes: 1 addition & 1 deletion lib/easy-deployment/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Easy
module Deployment
VERSION = "0.0.8"
VERSION = "0.0.9"
end
end
20 changes: 20 additions & 0 deletions lib/easy/deployment/apache.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Define some defaults for capistrano deploys.
# To load this capistrano configuraiton, require 'easy/deployment/apache' from deploy.rb

Capistrano::Configuration.instance(:must_exist).load do
namespace :apache do
desc "Configure this site & Reload the apache configuration"
task :configure, :roles => :app, :except => { :no_release => true } do
run "cp -f #{current_path}/config/deploy/#{stage}/apache/* /etc/apache2/sites-enabled/"
end

[:stop, :start, :restart].each do |action|
desc "#{action.to_s.capitalize} Apache"
task action, :roles => :web do
run "sudo apache2ctl #{action.to_s}"
end
end
end

after 'apache:configure', 'apache:restart'
end
29 changes: 23 additions & 6 deletions lib/easy/deployment/capistrano.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,24 @@
default_run_options[:pty] = true

namespace :deploy do
desc "Initial deploy including database creation and apache2 config setup"
task :inital do
set :migrate_target, :latest
update # updates_code and creates symlink
create_db
migrate
top.namespace :easy do
namespace(:logrotate){setup}
namespace(:apache) {configure}
end
restart
end

# By default, we deploy using passenger as an app server
task :start do ; end
task :stop do ; end
task :restart, :roles => :app, :except => { :no_release => true } do
run "touch #{File.join(current_path,'tmp','restart.txt')}"
run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
end

desc "[internal] Copies the application configuration files for this environment"
Expand All @@ -25,15 +38,19 @@
end
end

desc "Allow deployment of a branch, commit or tag"
task :set_branch do
set :branch, ENV['tag'] || 'master'
end
end

namespace :web do
desc "Configure this site & Reload the apache configuration"
task :configure do
run "cp -f #{current_path}/config/deploy/#{stage}/apache/* /etc/apache2/sites-enabled/"
run "sudo apache2ctl -k graceful"
desc "Deprecated - use apache:configure instead"
task :configure, :roles => :app, :except => { :no_release => true } do
puts "Deprecated - use apache:configure instead"
end
end

after "deploy:update_code", "deploy:configure"

before 'deploy:update_code', 'deploy:set_branch' # allow specification of branch, tag or commit on the command line
end
28 changes: 28 additions & 0 deletions lib/easy/deployment/niet.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Define some defaults for capistrano deploys.
# To load this capistrano configuraiton, require 'easy/deployment/niet' from deploy.rb

Capistrano::Configuration.instance(:must_exist).load do
namespace :niet do
desc "Starts the niet process monitor"
task :start, roles: :job do
2.times do
run "niet -c #{current_path} bundle exec rake jobs:work RAILS_ENV=#{stage}"
end
end

desc "Restarts the niet process monitor"
task :restart, roles: :job do
run "killall -u deploy niet"
end

desc "Stops the niet process monitor"
task :stop, roles: :job do
run "killall -u deploy -QUIT niet"
end

desc "Diplays the status of the niet process monitor"
task :status, roles: :job do
run "ps -fu deploy"
end
end
end

0 comments on commit 29f17af

Please sign in to comment.