Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Capistrano deploy scripts

  • Loading branch information...
commit 2d83b17bf24c45aaa06e096d42c1d4d7480f8c3e 1 parent 1489ea1
Michael Nutt authored
View
1  .gitignore
@@ -1 +1,2 @@
/backups
+/config/app.json
View
4 Capfile
@@ -0,0 +1,4 @@
+load 'deploy' if respond_to?(:namespace) # cap2 differentiator
+Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
+
+load 'config/deploy' # remove this line to skip loading any of the default tasks
View
8 config/app.json.sample
@@ -0,0 +1,8 @@
+{
+ "name" : "Hummingbird",
+
+ "capistrano" : {
+ "repository" : "git://github.com/mnutt/hummingbird.git",
+ "hummingbird_host" : "hummingbird.your-host.com"
+ }
+}
View
69 config/deploy.rb
@@ -0,0 +1,69 @@
+require 'json'
+
+settings = JSON.parse File.read(File.join(File.dirname(__FILE__), 'app.json'))
+
+set :application, "hummingbird"
+set :scm, :git
+
+set :repository, settings['capistrano']['repository']
+
+set :hummingbird_host, settings['capistrano']['hummingbird_host']
+
+role :web, hummingbird_host
+role :app, hummingbird_host
+role :db, hummingbird_host
+
+depend :remote, :command, 'git'
+
+set :git_enable_submodules, 1
+set :deploy_to, "/var/www/#{application}"
+
+default_run_options[:pty] = true
+
+namespace :deploy do
+ task :restart, :roles => :app, :except => { :no_release => true } do
+ run "#{try_sudo} restart hummingbird"
+ run "#{try_sudo} restart hummingbird_monitor"
+ end
+
+ task :pull_express_submodules, :roles => :app do
+ run "cd #{latest_release}/deps/express && git submodule update --init"
+ end
+end
+
+desc 'Tail the production log'
+task :tail, :roles => :app do
+ run "tail -100f #{shared_path}/log/hummingbird.log"
+end
+
+desc 'Tail nginx error log'
+task :tail_error, :roles => :app do
+ sudo "tail -100f /var/log/nginx/error.log"
+end
+
+namespace :update do
+ desc 'Creates symlinks for shared resources'
+ task :symlink_shared do
+ symlinks = { 'log' => 'log' }
+ symlinks.each do |shared, current|
+ run "rm -rf #{latest_release}/#{current}"
+ run "ln -s #{shared_path}/#{shared} #{latest_release}/#{current}"
+ end
+ end
+end
+
+desc "Backup the remote production database"
+task :backup, :roles => :db do
+ filename = "#{application}.dump.#{Time.now.to_s.gsub(/[^0-9\-]/, '')}.bson"
+ file = "/tmp/hummingbird/metrics.bson"
+ on_rollback { run "rm #{file}" }
+ run "echo $PATH; mongodump -d hummingbird -c metrics -o /tmp" do |ch, stream, data|
+ puts data
+ end
+ `mkdir -p #{File.dirname(__FILE__)}/../backups/`
+ get file, "backups/#{filename}"
+ run "rm #{file}"
+end
+
+after 'deploy:update_code', 'update:symlink_shared'
+after 'deploy:update_code', 'deploy:pull_express_submodules'
Please sign in to comment.
Something went wrong with that request. Please try again.