Created
November 6, 2012 17:56
-
-
Save bootandy/4026354 to your computer and use it in GitHub Desktop.
A sample CAP file capistrano
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| load 'deploy' if respond_to?(:namespace) | |
| require 'railsless-deploy' | |
| require 'capistrano_colors' | |
| set :application, "grata" | |
| set :user, "ubuntu" | |
| set :use_sudo, false | |
| # Forward your github ssh keys to the server | |
| ssh_options[:forward_agent] = true | |
| default_run_options[:pty] = true | |
| set :scm, :git | |
| set :repository, "[email protected]:marcoi/Grata.git" | |
| set :deploy_via, :remote_cache | |
| set :deploy_to, "/home/#{user}/cap/#{application}" | |
| default_run_options[:shell] = '/bin/bash' | |
| ssh_options[:keys] = ["KEY.pem"] # make sure you also have the publickey | |
| desc "Run on staging server" | |
| task :staging do | |
| server "176.34.176.2", :app, :web, :db, :primary => true | |
| set :config_env, 'staging' | |
| end | |
| desc "Run on production server" | |
| task :production do | |
| answer = Capistrano::CLI.ui.ask(" | |
| You are deploying to PRODUCTION , Are you sure? | |
| Type YES (uppercase) to continue:") | |
| if (answer == 'YES') | |
| Capistrano::CLI.ui.say "Deploying" | |
| else | |
| Capistrano::CLI.ui.say "Aborting" | |
| abort | |
| end | |
| server "54.246.98.1", :app, :web, :db, :primary => true | |
| set :config_env, 'prod' | |
| end | |
| set :runner, user | |
| set :admin_runner, user | |
| namespace :deploy do | |
| task :start do ; end | |
| task :stop do ; end | |
| task :restart_server, :roles => :app do | |
| runner = "echo 'going to supervisor'" | |
| run "exec #{runner}" | |
| venv = "source /home/ubuntu/virtual_env/grata/bin/activate" | |
| run "#{venv}; pip install -r /home/ubuntu/cap/grata/current/requirements.txt" | |
| # We dont restart mongo: sudo supervisorctl restart tornado | |
| runner = "sudo supervisorctl restart tornado" | |
| run "exec #{runner}" | |
| runner = "sudo supervisorctl restart nginx" | |
| run "exec #{runner}" | |
| end | |
| desc "Copies config over" | |
| task :copy_config, :roles => :app do | |
| run = "exec echo 'copying ordinary config'" | |
| config_copy = "sudo cp /home/ubuntu/cap/grata/current/deploy/manual_config/*.conf /etc/supervisor/conf.d/" | |
| run "exec #{config_copy}" | |
| if (config_env) | |
| run = "exec 'copying custom config " + config_env + "'" | |
| config_copy = "sudo cp /home/ubuntu/cap/grata/current/deploy/manual_config/"+config_env+"/*.conf /etc/supervisor/conf.d/" | |
| run "exec #{config_copy}" | |
| end | |
| end | |
| end | |
| after "deploy:finalize_update", "deploy:copy_config" | |
| after "deploy:symlink", "deploy:restart_server" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment