Commit c40a2669 authored by Sarah Mei's avatar Sarah Mei

Deploy with capistrano.

parent c0bb1e8c
......@@ -30,6 +30,7 @@ gem 'roxml', :git => 'git://github.com/Empact/roxml.git', :ref => '7ea9a9ffd2338
gem 'addressable', '2.2.2', :require => 'addressable/uri'
gem 'json', '1.4.6'
gem 'http_accept_language', :git => 'git://github.com/iain/http_accept_language.git', :ref => '0b78aa7849fc90cf9e12'
gem 'capistrano', '2.5.19'
gem 'thin', '1.2.7', :require => false
......
......@@ -104,6 +104,12 @@ GEM
bcrypt-ruby (2.1.4)
builder (2.1.2)
bunny (0.6.0)
capistrano (2.5.19)
highline
net-scp (>= 1.0.0)
net-sftp (>= 2.0.0)
net-ssh (>= 2.0.14)
net-ssh-gateway (>= 1.0.0)
capybara (0.3.9)
culerity (>= 0.2.4)
mime-types (>= 1.16)
......@@ -221,7 +227,13 @@ GEM
multipart-post (1.1.0)
mysql2 (0.2.6)
net-ldap (0.1.1)
net-scp (1.0.4)
net-ssh (>= 1.99.1)
net-sftp (2.0.5)
net-ssh (>= 2.0.9)
net-ssh (2.0.24)
net-ssh-gateway (1.0.1)
net-ssh (>= 1.99.1)
nokogiri (1.4.3.1)
oa-basic (0.1.6)
multi_json (~> 0.0.2)
......@@ -366,6 +378,7 @@ DEPENDENCIES
addressable (= 2.2.2)
aws (= 2.3.32)
bundler (>= 1.0.0)
capistrano (= 2.5.19)
capybara (~> 0.3.9)
carrierwave!
chef (= 0.9.12)
......
......@@ -2,151 +2,53 @@
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
require 'rubygems'
require 'eventmachine'
config = YAML.load_file(File.dirname(__FILE__) + '/deploy_config.yml')
config = config['production']
all = config['cross_server']
set :rails_env, 'production'
set :application, 'diaspora'
set :deploy_to, config['deploy_to']
set :current_dir, config['current_dir']
set :backers, config['servers']['backer']
set :application, "diaspora"
set :deploy_to, all['deploy_to']
#set :runner, "diasporaroot"
#set :current_dir, ""
# Source code
set :scm, :git
set :user, all['user']
#set :user, ARGV[0]
set :password, all['password'] if all['password']
set :user, config['user']
set :password, config['password']
set :use_sudo, false
set :scm_verbose, true
set :repository, all['repo']
set :branch, all['branch']
set :repository, config['repo']
set :repository_cache, "remote_cache"
set :deploy_via, :checkout
#ssh_options[:forward_agent] = true
#set :ssh_options, { :forward_agent => true }
#
set :rails_env, ENV['rails_env'] || ENV['RAILS_ENV'] || all['default_env']
role :tom, "tom.joindiaspora.com"
backers.each{ |backer|
role :backer, "#{backer['username']}.joindiaspora.com", :number => backer['number']
}
#role :ci, "ci.joindiaspora.com"
# If you are using Passenger mod_rails uncomment this:
# if you're still using the script/reapear helper you will need
# these http://github.com/rails/irs_process_scripts
# Start Nginx
after "deploy:cold" do
#run("nginx")
end
server config['server'], :app, :web, :db, :primary => true
namespace :deploy do
task :symlink_images do
run "mkdir -p #{shared_path}/uploads"
run "ln -s -f #{shared_path}/uploads #{current_path}/public/uploads"
end
task :symlink_bundle do
run "mkdir -p #{shared_path}/bundle"
run "ln -s -f #{shared_path}/bundle #{current_path}/vendor/bundle"
end
task :symlink_config do
run "touch #{shared_path}/app_config.yml"
run "ln -s -f #{shared_path}/app_config.yml #{current_path}/config/app_config.yml"
end
task :symlink_oauth_keys_config do
run "touch #{shared_path}/oauth_keys.yml"
run "ln -s -f #{shared_path}/oauth_keys.yml #{current_path}/config/oauth_keys.yml"
task :symlink_config_files do
run "ln -s -f #{shared_path}/config/database.yml #{current_path}/config/database.yml"
run "ln -s -f #{shared_path}/config/app_config.yml #{current_path}/config/app_config.yml"
run "ln -s -f #{shared_path}/config/oauth_keys.yml #{current_path}/config/oauth_keys.yml"
end
task :start do
start_mongo
start_thin
start_websocket
task :symlink_cookie_secret do
run "ln -s -f #{shared_path}/config/initializers/secret_token.rb #{current_path}/config/initializers/secret_token.rb"
end
task :start_websocket do
run("cd #{current_path} && bundle exec ruby ./script/websocket_server.rb > /dev/null&")
task :bundle_static_assets do
run "cd #{current_path} && sass --update public/stylesheets/sass:public/stylesheets"
run "cd #{current_path} && bundle exec jammit"
end
task :start_mongo do
run("mkdir -p -v #{current_path}/log/db/ ")
run("mkdir -p -v #{shared_path}/db/")
run("mongod --fork --logpath #{current_path}/log/db/mongolog.txt --dbpath #{shared_path}/db/ " )
task :restart do
run "killall ruby"
end
task :start_thin do
run("mkdir -p -v #{current_path}/log/thin/ ")
run("cd #{current_path} && bundle exec thin start -C config/thin.yml")
task :start do
# daemontools FTW
end
task :stop do
stop_thin
run("killall -s 2 mongod || true")
end
task :stop_thin do
run("killall -s 2 ruby || true")
#run("cd #{current_path} && bundle exec thin stop -C config/thin.yml || true")
end
task :restart, :roles => :app, :except => { :no_release => true } do
stop
start
end
task :bundle_gems do
run "cd #{current_path} && bundle install"
end
task :reinstall_old_bundler do
#run ("rm #{current_path}/Gemfile.lock || true")
run 'gem list | cut -d" " -f1 | xargs gem uninstall -aIx || true '
run "gem install bundler -v 0.9.26 || true"
end
task :update_bundler do
run 'gem install bundler'
end
task :migrate do
end
end
namespace :cloud do
task :reboot do
run('reboot')
end
task :clear_bundle do
run('cd && rm -r -f .bundle')
end
end
namespace :db do
task :purge, :roles => [:tom, :backer] do
run "cd #{current_path} && bundle exec rake db:purge --trace RAILS_ENV=#{rails_env}"
end
task :tom_seed, :roles => :tom do
run "cd #{current_path} && bundle exec rake db:seed:tom --trace RAILS_ENV=#{rails_env}"
end
task :backer_seed, :roles => :backer do
run "cd #{current_path} && bundle exec rake db:seed:backer --trace RAILS_ENV=#{rails_env}"
end
task :reset do
purge
backer_seed
tom_seed
run "killall ruby"
end
end
after "deploy:symlink", "deploy:symlink_images", "deploy:symlink_bundle", 'deploy:symlink_config', 'deploy:symlink_oauth_keys_config'
after "deploy:symlink", "deploy:symlink_config_files", "deploy:symlink_cookie_secret", "deploy:bundle_static_assets"
\ No newline at end of file
# Copyright (c) 2010, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
production:
server: 'example.com'
deploy_to: '/var/www/diaspora'
current_dir: 'diaspora'
user: 'diaspora'
password: 'password'
repo: 'git://github.com/diaspora/diaspora.git'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment