capone 0.0.5 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +52 -0
 - data/recipes/daemon_strategies/mongrel_cluster.rb +6 -0
 - data/recipes/daemon_strategies/passenger.rb +17 -0
 - data/recipes/daemon_strategy.rb +7 -0
 - data/recipes/db.rb +98 -0
 - data/recipes/defaults.rb +30 -0
 - data/recipes/delayed_job.rb +7 -0
 - data/recipes/gems.rb +23 -0
 - data/recipes/nginx.rb +10 -4
 - data/recipes/whenever.rb +16 -12
 - metadata +22 -18
 - data/README.rdoc +0 -14
 - data/Rakefile +0 -55
 - data/recipes/backup.rb +0 -17
 - data/recipes/deploy.rb +0 -27
 - data/recipes/git.rb +0 -14
 - data/recipes/install.rb +0 -105
 - data/recipes/update.rb +0 -26
 - data/tasks/capone_tasks.rake +0 -17
 - data/templates/Capfile +0 -3
 - data/templates/config/deploy.rb +0 -29
 - data/templates/config/mongrel_cluster.yml.erb +0 -18
 - data/templates/config/monitrc +0 -57
 - data/templates/system/nginx.conf +0 -58
 
    
        data/README.md
    ADDED
    
    | 
         @@ -0,0 +1,52 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Capone
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            Capone is the set of Capistrano recipes that help me to deploy my
         
     | 
| 
      
 4 
     | 
    
         
            +
            applications.
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            Capone by default uses Mongrel cluster (or Passenger) as an application
         
     | 
| 
      
 7 
     | 
    
         
            +
            server, nginx as a web server, MySQL as a database server and git as a SCM.
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            The latest version of Capone was inspired by Rubaidh's
         
     | 
| 
      
 10 
     | 
    
         
            +
            [Rubaidhstrano](http://github.com/rubaidh/rubaidhstrano) and some code has
         
     | 
| 
      
 11 
     | 
    
         
            +
            been borrowed from its sources.
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            ## Installation
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            Capone could be installed either as a gem or as Rails plugin.
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            ### Gem (preferred)
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            Add to the end of your `config/environments/development.rb` file:
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                config.gem 'capone', :lib => false, :version => '>= 0.1.0'
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            ### Rails plugin
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                ./script/plugin install git://github.com/denis/capone.git
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
            ## Example usage
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            To start using Capone you just need to add `require "capone"` to your
         
     | 
| 
      
 30 
     | 
    
         
            +
            `config/deploy.rb` file (only if Capone is installed as a gem) and set some
         
     | 
| 
      
 31 
     | 
    
         
            +
            variables:
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                require "capone"
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                set :application, "set your application name here"
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                set :repository,  "set your repository location here"
         
     | 
| 
      
 38 
     | 
    
         
            +
                set :host, "set your host here"
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
            ## Features
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
            In process...
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
            ## Thanks
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
            - Jamis Buck for [Capistrano](http://github.com/jamis/capistrano),
         
     | 
| 
      
 47 
     | 
    
         
            +
            - Rubaidh Ltd for their awesome
         
     | 
| 
      
 48 
     | 
    
         
            +
              [Rubaidhstrano](http://github.com/rubaidh/rubaidhstrano).
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
            ## Copyright
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
            Copyright (c) 2009 Denis Barushev. See LICENSE for details.
         
     | 
| 
         @@ -0,0 +1,17 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            namespace :deploy do
         
     | 
| 
      
 2 
     | 
    
         
            +
              desc "Start application."
         
     | 
| 
      
 3 
     | 
    
         
            +
              task :start, :roles => :app do
         
     | 
| 
      
 4 
     | 
    
         
            +
                run "touch #{current_release}/tmp/restart.txt"
         
     | 
| 
      
 5 
     | 
    
         
            +
              end
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
              desc "Stop application."
         
     | 
| 
      
 8 
     | 
    
         
            +
              task :stop, :roles => :app do
         
     | 
| 
      
 9 
     | 
    
         
            +
              end
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
              desc "Restart application."
         
     | 
| 
      
 12 
     | 
    
         
            +
              task :restart, :roles => :app do
         
     | 
| 
      
 13 
     | 
    
         
            +
                run "touch #{current_release}/tmp/restart.txt"
         
     | 
| 
      
 14 
     | 
    
         
            +
              end
         
     | 
| 
      
 15 
     | 
    
         
            +
            end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            depend :remote, :gem, "passenger", ">=2.2.2"
         
     | 
    
        data/recipes/db.rb
    ADDED
    
    | 
         @@ -0,0 +1,98 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            namespace :capone do
         
     | 
| 
      
 2 
     | 
    
         
            +
              namespace :db do
         
     | 
| 
      
 3 
     | 
    
         
            +
                desc <<-DESC
         
     | 
| 
      
 4 
     | 
    
         
            +
                  Create MySQL user and database using data from config/database.yml.
         
     | 
| 
      
 5 
     | 
    
         
            +
                DESC
         
     | 
| 
      
 6 
     | 
    
         
            +
                task :setup, :roles => :db, :only => { :primary => true } do
         
     | 
| 
      
 7 
     | 
    
         
            +
                  config = YAML::load(File.open("config/database.yml"))[rails_env]
         
     | 
| 
      
 8 
     | 
    
         
            +
                  root_password = Capistrano::CLI.password_prompt(prompt="Enter a root password for MySQL: ")
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                  run "mysql --user='root' --password='#{root_password}' -e \"CREATE DATABASE IF NOT EXISTS #{config["database"]} DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; GRANT ALL PRIVILEGES ON #{config["database"]}.* TO '#{config["username"]}'@'localhost' IDENTIFIED BY '#{config["password"]}' WITH GRANT OPTION;\""
         
     | 
| 
      
 11 
     | 
    
         
            +
                end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                desc <<-DESC
         
     | 
| 
      
 14 
     | 
    
         
            +
                  Load fixtures from db/fixtures to the database.
         
     | 
| 
      
 15 
     | 
    
         
            +
                DESC
         
     | 
| 
      
 16 
     | 
    
         
            +
                task :load_fixtures, :roles => :db, :only => { :primary => true } do
         
     | 
| 
      
 17 
     | 
    
         
            +
                  run "rake db:fixtures:load FIXTURES_PATH=db/fixtures RAILS_ENV=#{rails_env} -f #{release_path}/Rakefile"
         
     | 
| 
      
 18 
     | 
    
         
            +
                end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                desc <<-DESC
         
     | 
| 
      
 21 
     | 
    
         
            +
                  Dumps the database for the current environment into db/env-data.sql.bz2.
         
     | 
| 
      
 22 
     | 
    
         
            +
                  Any existing backup will be overwritten.
         
     | 
| 
      
 23 
     | 
    
         
            +
                DESC
         
     | 
| 
      
 24 
     | 
    
         
            +
                task :backup, :roles => :db, :only => { :primary => true } do
         
     | 
| 
      
 25 
     | 
    
         
            +
                  config = YAML::load(File.open("config/database.yml"))[rails_env]
         
     | 
| 
      
 26 
     | 
    
         
            +
                  case config["adapter"]
         
     | 
| 
      
 27 
     | 
    
         
            +
                    when "mysql"
         
     | 
| 
      
 28 
     | 
    
         
            +
                      cmd = ["mysqldump"]
         
     | 
| 
      
 29 
     | 
    
         
            +
                      cmd << "--host='#{config['host']}'" unless config["host"].nil?
         
     | 
| 
      
 30 
     | 
    
         
            +
                      cmd << "--user='#{config['username'].nil? ? 'root' : config['username']}'"
         
     | 
| 
      
 31 
     | 
    
         
            +
                      cmd << "--password='#{config['password']}'" unless config["password"].nil?
         
     | 
| 
      
 32 
     | 
    
         
            +
                      cmd << config["database"]
         
     | 
| 
      
 33 
     | 
    
         
            +
                      cmd << "| bzip2 > #{release_path}/db/#{rails_env}-data.sql.bz2"
         
     | 
| 
      
 34 
     | 
    
         
            +
                      run cmd.join(" ")
         
     | 
| 
      
 35 
     | 
    
         
            +
                  else
         
     | 
| 
      
 36 
     | 
    
         
            +
                    puts "Task not supported by '#{config['adapter']}'."
         
     | 
| 
      
 37 
     | 
    
         
            +
                  end
         
     | 
| 
      
 38 
     | 
    
         
            +
                end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
                desc <<-DESC
         
     | 
| 
      
 41 
     | 
    
         
            +
                  Dumps the database for the current environment and take a local copy.
         
     | 
| 
      
 42 
     | 
    
         
            +
                DESC
         
     | 
| 
      
 43 
     | 
    
         
            +
                task :download_backup, :roles => :db, :only => { :primary => true } do
         
     | 
| 
      
 44 
     | 
    
         
            +
                  backup
         
     | 
| 
      
 45 
     | 
    
         
            +
                  get "#{latest_release}/db/#{rails_env}-data.sql.bz2", "db/#{rails_env}-data.sql.bz2"
         
     | 
| 
      
 46 
     | 
    
         
            +
                end
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                desc <<-DESC
         
     | 
| 
      
 49 
     | 
    
         
            +
                  Loads an existing database dump into the current environment's database.
         
     | 
| 
      
 50 
     | 
    
         
            +
                  WARNING: this completely nukes the existing database! Use SOURCE_ENV to
         
     | 
| 
      
 51 
     | 
    
         
            +
                  specify which dump should be loaded. Defaults to 'production'."
         
     | 
| 
      
 52 
     | 
    
         
            +
                DESC
         
     | 
| 
      
 53 
     | 
    
         
            +
                task :load_backup do
         
     | 
| 
      
 54 
     | 
    
         
            +
                  run_locally "rake db:drop"
         
     | 
| 
      
 55 
     | 
    
         
            +
                  run_locally "rake db:create"
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
                  config = YAML::load(File.open("config/database.yml"))[rails_env]
         
     | 
| 
      
 58 
     | 
    
         
            +
                  case config["adapter"]
         
     | 
| 
      
 59 
     | 
    
         
            +
                    when "mysql"
         
     | 
| 
      
 60 
     | 
    
         
            +
                      cmd = ["bzcat db/production-data.sql.bz2 | mysql"]
         
     | 
| 
      
 61 
     | 
    
         
            +
                      cmd << "--host='#{config['host']}'" unless config["host"].nil?
         
     | 
| 
      
 62 
     | 
    
         
            +
                      cmd << "--user='#{config['username'].nil? ? 'root' : config['username']}'"
         
     | 
| 
      
 63 
     | 
    
         
            +
                      cmd << "--password='#{config['password']}'" unless config["password"].nil?
         
     | 
| 
      
 64 
     | 
    
         
            +
                      cmd << config["database"]
         
     | 
| 
      
 65 
     | 
    
         
            +
                      run_locally cmd.join(" ")
         
     | 
| 
      
 66 
     | 
    
         
            +
                  else
         
     | 
| 
      
 67 
     | 
    
         
            +
                    puts "Task not supported by '#{config['adapter']}'."
         
     | 
| 
      
 68 
     | 
    
         
            +
                  end
         
     | 
| 
      
 69 
     | 
    
         
            +
                end
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
                task :replicate do
         
     | 
| 
      
 72 
     | 
    
         
            +
                  download_backup
         
     | 
| 
      
 73 
     | 
    
         
            +
                  load_backup
         
     | 
| 
      
 74 
     | 
    
         
            +
                end
         
     | 
| 
      
 75 
     | 
    
         
            +
              end
         
     | 
| 
      
 76 
     | 
    
         
            +
            end
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
            on :load do
         
     | 
| 
      
 79 
     | 
    
         
            +
              if fetch(:setup_database_after_deploy_setup, true)
         
     | 
| 
      
 80 
     | 
    
         
            +
                after "deploy:setup", "capone:db:setup"
         
     | 
| 
      
 81 
     | 
    
         
            +
              end
         
     | 
| 
      
 82 
     | 
    
         
            +
              if fetch(:load_fixtures_to_database_after_deploy_cold, false)
         
     | 
| 
      
 83 
     | 
    
         
            +
                after "deploy:cold", "capone:db:load_fixtures"
         
     | 
| 
      
 84 
     | 
    
         
            +
              end
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
              if fetch(:backup_database_before_migrations, false)
         
     | 
| 
      
 87 
     | 
    
         
            +
                before "deploy:migrate", "capone:db:backup"
         
     | 
| 
      
 88 
     | 
    
         
            +
              end
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
              if fetch(:disable_web_during_migrations, false)
         
     | 
| 
      
 91 
     | 
    
         
            +
                before "deploy:migrations", "deploy:web:disable"
         
     | 
| 
      
 92 
     | 
    
         
            +
                after  "deploy:migrations", "deploy:web:enable"
         
     | 
| 
      
 93 
     | 
    
         
            +
              end
         
     | 
| 
      
 94 
     | 
    
         
            +
            end
         
     | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
      
 96 
     | 
    
         
            +
            depend :remote, :command, "mysql"
         
     | 
| 
      
 97 
     | 
    
         
            +
            depend :remote, :command, "mysqldump"
         
     | 
| 
      
 98 
     | 
    
         
            +
            depend :remote, :command, "bzip2"
         
     | 
    
        data/recipes/defaults.rb
    ADDED
    
    | 
         @@ -0,0 +1,30 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            set :scm, :git
         
     | 
| 
      
 2 
     | 
    
         
            +
            set :deploy_via, :remote_cache
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            set :rails_env, "production"
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            set(:deploy_to) { "/var/www/apps/#{application}" }
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            role(:app) { host }
         
     | 
| 
      
 9 
     | 
    
         
            +
            role(:web) { host }
         
     | 
| 
      
 10 
     | 
    
         
            +
            role(:db, :primary => true) { host }
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            set :use_sudo, false
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            # Needed for proper password prompts
         
     | 
| 
      
 15 
     | 
    
         
            +
            default_run_options[:pty] = true
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            # You can redefine these variables in your config/deploy.rb
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            # set :daemon_strategy, :mongrel_cluster
         
     | 
| 
      
 20 
     | 
    
         
            +
            # set :web_server, :nginx
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            # set :install_gems, true
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            # set :backup_database_before_migrations, false
         
     | 
| 
      
 25 
     | 
    
         
            +
            # set :disable_web_during_migrations, false
         
     | 
| 
      
 26 
     | 
    
         
            +
            # set :setup_database_after_deploy_setup, true
         
     | 
| 
      
 27 
     | 
    
         
            +
            # set :load_fixtures_to_database_after_deploy_cold, false
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            # set :whenever, false
         
     | 
| 
      
 30 
     | 
    
         
            +
            # set :delayed_job, false
         
     | 
    
        data/recipes/gems.rb
    ADDED
    
    | 
         @@ -0,0 +1,23 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            namespace :capone do
         
     | 
| 
      
 2 
     | 
    
         
            +
              namespace :gems do
         
     | 
| 
      
 3 
     | 
    
         
            +
                desc <<-DESC
         
     | 
| 
      
 4 
     | 
    
         
            +
                  Install gems needed by application.
         
     | 
| 
      
 5 
     | 
    
         
            +
                DESC
         
     | 
| 
      
 6 
     | 
    
         
            +
                task :install, :roles => :app do
         
     | 
| 
      
 7 
     | 
    
         
            +
                  run "rake gems:install -f #{release_path}/Rakefile RAILS_ENV=#{rails_env}"
         
     | 
| 
      
 8 
     | 
    
         
            +
                end
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                desc <<-DESC
         
     | 
| 
      
 11 
     | 
    
         
            +
                  Update installed gems.
         
     | 
| 
      
 12 
     | 
    
         
            +
                DESC
         
     | 
| 
      
 13 
     | 
    
         
            +
                task :update, :roles => :app do
         
     | 
| 
      
 14 
     | 
    
         
            +
                  sudo "gem update --no-rdoc --no-ri"
         
     | 
| 
      
 15 
     | 
    
         
            +
                end
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
            end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            on :load do
         
     | 
| 
      
 20 
     | 
    
         
            +
              if fetch(:install_gems, true)
         
     | 
| 
      
 21 
     | 
    
         
            +
                after "deploy:update_code", "capone:gems:install"
         
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
            end
         
     | 
    
        data/recipes/nginx.rb
    CHANGED
    
    | 
         @@ -3,7 +3,7 @@ namespace :capone do 
     | 
|
| 
       3 
3 
     | 
    
         
             
                desc <<-DESC
         
     | 
| 
       4 
4 
     | 
    
         
             
                  Enable virtual host.
         
     | 
| 
       5 
5 
     | 
    
         
             
                DESC
         
     | 
| 
       6 
     | 
    
         
            -
                task :enable_vhost do
         
     | 
| 
      
 6 
     | 
    
         
            +
                task :enable_vhost, :roles => :web do
         
     | 
| 
       7 
7 
     | 
    
         
             
                  sudo "ln -fs #{current_path}/config/nginx.conf /etc/nginx/sites-enabled/#{application}"
         
     | 
| 
       8 
8 
     | 
    
         
             
                  sudo "/etc/init.d/nginx reload"
         
     | 
| 
       9 
9 
     | 
    
         
             
                end
         
     | 
| 
         @@ -11,16 +11,22 @@ namespace :capone do 
     | 
|
| 
       11 
11 
     | 
    
         
             
                desc <<-DESC
         
     | 
| 
       12 
12 
     | 
    
         
             
                  Disable virtual host.
         
     | 
| 
       13 
13 
     | 
    
         
             
                DESC
         
     | 
| 
       14 
     | 
    
         
            -
                task :disable_vhost do
         
     | 
| 
      
 14 
     | 
    
         
            +
                task :disable_vhost, :roles => :web do
         
     | 
| 
       15 
15 
     | 
    
         
             
                  sudo "rm /etc/nginx/sites-enabled/#{application}"
         
     | 
| 
       16 
16 
     | 
    
         
             
                  sudo "/etc/init.d/nginx reload"
         
     | 
| 
       17 
17 
     | 
    
         
             
                end
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
       19 
19 
     | 
    
         
             
                desc <<-DESC
         
     | 
| 
       20 
     | 
    
         
            -
                  Reload nginx configuration if config file was changed.
         
     | 
| 
      
 20 
     | 
    
         
            +
                  Reload nginx configuration if the application nginx virtual host config file was changed.
         
     | 
| 
       21 
21 
     | 
    
         
             
                DESC
         
     | 
| 
       22 
     | 
    
         
            -
                task :reload_if_config_file_changed do
         
     | 
| 
      
 22 
     | 
    
         
            +
                task :reload_if_config_file_changed, :roles => :web do
         
     | 
| 
       23 
23 
     | 
    
         
             
                  run "bash -c \"if ! cmp #{previous_release}/config/nginx.conf #{current_path}/config/nginx.conf; then #{sudo} /etc/init.d/nginx reload; fi\""
         
     | 
| 
       24 
24 
     | 
    
         
             
                end
         
     | 
| 
       25 
25 
     | 
    
         
             
              end
         
     | 
| 
       26 
26 
     | 
    
         
             
            end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
            if fetch(:web_server, :nginx) == :nginx
         
     | 
| 
      
 29 
     | 
    
         
            +
              before "deploy:start",   "capone:nginx:enable_vhost"
         
     | 
| 
      
 30 
     | 
    
         
            +
              after  "deploy:stop",    "capone:nginx:disable_vhost"
         
     | 
| 
      
 31 
     | 
    
         
            +
              after  "deploy:restart", "capone:nginx:reload_if_config_file_changed"
         
     | 
| 
      
 32 
     | 
    
         
            +
            end
         
     | 
    
        data/recipes/whenever.rb
    CHANGED
    
    | 
         @@ -1,12 +1,16 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
                 
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
                 
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            namespace :capone do
         
     | 
| 
      
 2 
     | 
    
         
            +
              namespace :whenever do
         
     | 
| 
      
 3 
     | 
    
         
            +
                desc <<-DESC
         
     | 
| 
      
 4 
     | 
    
         
            +
                  Update the crontab file with whenever.
         
     | 
| 
      
 5 
     | 
    
         
            +
                DESC
         
     | 
| 
      
 6 
     | 
    
         
            +
                task :update_crontab, :roles => :db do
         
     | 
| 
      
 7 
     | 
    
         
            +
                  run "cd #{release_path} && whenever --update-crontab #{application}"
         
     | 
| 
      
 8 
     | 
    
         
            +
                end
         
     | 
| 
      
 9 
     | 
    
         
            +
              end
         
     | 
| 
      
 10 
     | 
    
         
            +
            end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            on :load do
         
     | 
| 
      
 13 
     | 
    
         
            +
              if fetch(:whenever, false)
         
     | 
| 
      
 14 
     | 
    
         
            +
                after "deploy:symlink", "capone:whenever:update_crontab"
         
     | 
| 
      
 15 
     | 
    
         
            +
              end
         
     | 
| 
      
 16 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification 
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: capone
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version 
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.9
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors: 
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Denis Barushev
         
     | 
| 
         @@ -9,10 +9,19 @@ autorequire: 
     | 
|
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
            date: 2009-09 
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2009-12-09 00:00:00 +00:00
         
     | 
| 
       13 
13 
     | 
    
         
             
            default_executable: 
         
     | 
| 
       14 
     | 
    
         
            -
            dependencies:  
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
      
 14 
     | 
    
         
            +
            dependencies: 
         
     | 
| 
      
 15 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency 
         
     | 
| 
      
 16 
     | 
    
         
            +
              name: capistrano
         
     | 
| 
      
 17 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 18 
     | 
    
         
            +
              version_requirement: 
         
     | 
| 
      
 19 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 20 
     | 
    
         
            +
                requirements: 
         
     | 
| 
      
 21 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 22 
     | 
    
         
            +
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 23 
     | 
    
         
            +
                    version: 2.5.0
         
     | 
| 
      
 24 
     | 
    
         
            +
                version: 
         
     | 
| 
       16 
25 
     | 
    
         
             
            description: 
         
     | 
| 
       17 
26 
     | 
    
         
             
            email: barushev@gmail.com
         
     | 
| 
       18 
27 
     | 
    
         
             
            executables: []
         
     | 
| 
         @@ -21,25 +30,20 @@ extensions: [] 
     | 
|
| 
       21 
30 
     | 
    
         | 
| 
       22 
31 
     | 
    
         
             
            extra_rdoc_files: 
         
     | 
| 
       23 
32 
     | 
    
         
             
            - LICENSE
         
     | 
| 
       24 
     | 
    
         
            -
            - README. 
     | 
| 
      
 33 
     | 
    
         
            +
            - README.md
         
     | 
| 
       25 
34 
     | 
    
         
             
            files: 
         
     | 
| 
       26 
35 
     | 
    
         
             
            - LICENSE
         
     | 
| 
       27 
     | 
    
         
            -
            - README. 
     | 
| 
       28 
     | 
    
         
            -
            - Rakefile
         
     | 
| 
      
 36 
     | 
    
         
            +
            - README.md
         
     | 
| 
       29 
37 
     | 
    
         
             
            - lib/capone.rb
         
     | 
| 
       30 
     | 
    
         
            -
            - recipes/ 
     | 
| 
       31 
     | 
    
         
            -
            - recipes/ 
     | 
| 
       32 
     | 
    
         
            -
            - recipes/ 
     | 
| 
       33 
     | 
    
         
            -
            - recipes/ 
     | 
| 
      
 38 
     | 
    
         
            +
            - recipes/daemon_strategies/mongrel_cluster.rb
         
     | 
| 
      
 39 
     | 
    
         
            +
            - recipes/daemon_strategies/passenger.rb
         
     | 
| 
      
 40 
     | 
    
         
            +
            - recipes/daemon_strategy.rb
         
     | 
| 
      
 41 
     | 
    
         
            +
            - recipes/db.rb
         
     | 
| 
      
 42 
     | 
    
         
            +
            - recipes/defaults.rb
         
     | 
| 
      
 43 
     | 
    
         
            +
            - recipes/delayed_job.rb
         
     | 
| 
      
 44 
     | 
    
         
            +
            - recipes/gems.rb
         
     | 
| 
       34 
45 
     | 
    
         
             
            - recipes/nginx.rb
         
     | 
| 
       35 
     | 
    
         
            -
            - recipes/update.rb
         
     | 
| 
       36 
46 
     | 
    
         
             
            - recipes/whenever.rb
         
     | 
| 
       37 
     | 
    
         
            -
            - tasks/capone_tasks.rake
         
     | 
| 
       38 
     | 
    
         
            -
            - templates/Capfile
         
     | 
| 
       39 
     | 
    
         
            -
            - templates/config/deploy.rb
         
     | 
| 
       40 
     | 
    
         
            -
            - templates/config/mongrel_cluster.yml.erb
         
     | 
| 
       41 
     | 
    
         
            -
            - templates/config/monitrc
         
     | 
| 
       42 
     | 
    
         
            -
            - templates/system/nginx.conf
         
     | 
| 
       43 
47 
     | 
    
         
             
            has_rdoc: true
         
     | 
| 
       44 
48 
     | 
    
         
             
            homepage: http://github.com/denis/capone
         
     | 
| 
       45 
49 
     | 
    
         
             
            licenses: []
         
     | 
    
        data/README.rdoc
    DELETED
    
    | 
         @@ -1,14 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            = Capone
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            Capone is the set of rake tasks and capistrano recipes that help to:
         
     | 
| 
       4 
     | 
    
         
            -
            * generate configs;
         
     | 
| 
       5 
     | 
    
         
            -
            * prepare servers for production use;
         
     | 
| 
       6 
     | 
    
         
            -
            * deploy applications;
         
     | 
| 
       7 
     | 
    
         
            -
            * maintain servers.
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
            Capone supports only Ubuntu 8.04 LTS as an OS, Mongrel as an application server,
         
     | 
| 
       10 
     | 
    
         
            -
            nginx as a web server, MySQL as a database server and Subversion or git as a SCM.
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
            == Copyright
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
            Copyright (c) 2009 Denis Barushev. See LICENSE for details.
         
     | 
    
        data/Rakefile
    DELETED
    
    | 
         @@ -1,55 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'rubygems'
         
     | 
| 
       2 
     | 
    
         
            -
            require 'rake'
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            begin
         
     | 
| 
       5 
     | 
    
         
            -
              require 'jeweler'
         
     | 
| 
       6 
     | 
    
         
            -
              Jeweler::Tasks.new do |gem|
         
     | 
| 
       7 
     | 
    
         
            -
                gem.name = "capone"
         
     | 
| 
       8 
     | 
    
         
            -
                gem.summary = "Capone is the set of rake tasks and capistrano recipes."
         
     | 
| 
       9 
     | 
    
         
            -
                gem.email = "barushev@gmail.com"
         
     | 
| 
       10 
     | 
    
         
            -
                gem.homepage = "http://github.com/denis/capone"
         
     | 
| 
       11 
     | 
    
         
            -
                gem.authors = ["Denis Barushev"]
         
     | 
| 
       12 
     | 
    
         
            -
                # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
         
     | 
| 
       13 
     | 
    
         
            -
                gem.files = %w(LICENSE README.rdoc Rakefile) + Dir.glob("{lib,recipes,tasks,templates}/**/*")
         
     | 
| 
       14 
     | 
    
         
            -
              end
         
     | 
| 
       15 
     | 
    
         
            -
            rescue LoadError
         
     | 
| 
       16 
     | 
    
         
            -
              puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
         
     | 
| 
       17 
     | 
    
         
            -
            end
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
            require 'rake/testtask'
         
     | 
| 
       20 
     | 
    
         
            -
            Rake::TestTask.new(:test) do |test|
         
     | 
| 
       21 
     | 
    
         
            -
              test.libs << 'lib' << 'test'
         
     | 
| 
       22 
     | 
    
         
            -
              test.pattern = 'test/**/*_test.rb'
         
     | 
| 
       23 
     | 
    
         
            -
              test.verbose = true
         
     | 
| 
       24 
     | 
    
         
            -
            end
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
            begin
         
     | 
| 
       27 
     | 
    
         
            -
              require 'rcov/rcovtask'
         
     | 
| 
       28 
     | 
    
         
            -
              Rcov::RcovTask.new do |test|
         
     | 
| 
       29 
     | 
    
         
            -
                test.libs << 'test'
         
     | 
| 
       30 
     | 
    
         
            -
                test.pattern = 'test/**/*_test.rb'
         
     | 
| 
       31 
     | 
    
         
            -
                test.verbose = true
         
     | 
| 
       32 
     | 
    
         
            -
              end
         
     | 
| 
       33 
     | 
    
         
            -
            rescue LoadError
         
     | 
| 
       34 
     | 
    
         
            -
              task :rcov do
         
     | 
| 
       35 
     | 
    
         
            -
                abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
         
     | 
| 
       36 
     | 
    
         
            -
              end
         
     | 
| 
       37 
     | 
    
         
            -
            end
         
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
            task :test => :check_dependencies
         
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
       41 
     | 
    
         
            -
            task :default => :test
         
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
            require 'rake/rdoctask'
         
     | 
| 
       44 
     | 
    
         
            -
            Rake::RDocTask.new do |rdoc|
         
     | 
| 
       45 
     | 
    
         
            -
              if File.exist?('VERSION')
         
     | 
| 
       46 
     | 
    
         
            -
                version = File.read('VERSION')
         
     | 
| 
       47 
     | 
    
         
            -
              else
         
     | 
| 
       48 
     | 
    
         
            -
                version = ""
         
     | 
| 
       49 
     | 
    
         
            -
              end
         
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
              rdoc.rdoc_dir = 'rdoc'
         
     | 
| 
       52 
     | 
    
         
            -
              rdoc.title = "capone #{version}"
         
     | 
| 
       53 
     | 
    
         
            -
              rdoc.rdoc_files.include('README*')
         
     | 
| 
       54 
     | 
    
         
            -
              rdoc.rdoc_files.include('lib/**/*.rb')
         
     | 
| 
       55 
     | 
    
         
            -
            end
         
     | 
    
        data/recipes/backup.rb
    DELETED
    
    | 
         @@ -1,17 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            namespace :capone do
         
     | 
| 
       2 
     | 
    
         
            -
              namespace :backup do
         
     | 
| 
       3 
     | 
    
         
            -
                desc <<-DESC
         
     | 
| 
       4 
     | 
    
         
            -
                  Backup all.
         
     | 
| 
       5 
     | 
    
         
            -
                DESC
         
     | 
| 
       6 
     | 
    
         
            -
                task :default do
         
     | 
| 
       7 
     | 
    
         
            -
                  mysql
         
     | 
| 
       8 
     | 
    
         
            -
                end
         
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
                desc <<-DESC
         
     | 
| 
       11 
     | 
    
         
            -
                  Backup MySQL database.
         
     | 
| 
       12 
     | 
    
         
            -
                DESC
         
     | 
| 
       13 
     | 
    
         
            -
                task :mysql, :roles => :db, :only => { :primary => true } do
         
     | 
| 
       14 
     | 
    
         
            -
                  run "echo 'Not implemented yet.'"
         
     | 
| 
       15 
     | 
    
         
            -
                end
         
     | 
| 
       16 
     | 
    
         
            -
              end
         
     | 
| 
       17 
     | 
    
         
            -
            end
         
     | 
    
        data/recipes/deploy.rb
    DELETED
    
    | 
         @@ -1,27 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            namespace :capone do
         
     | 
| 
       2 
     | 
    
         
            -
              namespace :deploy do
         
     | 
| 
       3 
     | 
    
         
            -
                desc <<-DESC
         
     | 
| 
       4 
     | 
    
         
            -
                  Create MySQL user and database using data from config/database.yml.
         
     | 
| 
       5 
     | 
    
         
            -
                DESC
         
     | 
| 
       6 
     | 
    
         
            -
                task :setup_db, :roles => :db, :only => { :primary => true } do
         
     | 
| 
       7 
     | 
    
         
            -
                  config = YAML::load(File.open("config/database.yml"))[rails_env]
         
     | 
| 
       8 
     | 
    
         
            -
                  root_password = Capistrano::CLI.password_prompt(prompt="Enter a root password for MySQL: ")
         
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
                  run "mysql -u root --password=#{root_password} -e \"CREATE DATABASE IF NOT EXISTS #{config["database"]} DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; GRANT ALL PRIVILEGES ON #{config["database"]}.* TO '#{config["username"]}'@'localhost' IDENTIFIED BY '#{config["password"]}' WITH GRANT OPTION;\""
         
     | 
| 
       11 
     | 
    
         
            -
                end
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
                desc <<-DESC
         
     | 
| 
       14 
     | 
    
         
            -
                  Install gems needed by application.
         
     | 
| 
       15 
     | 
    
         
            -
                DESC
         
     | 
| 
       16 
     | 
    
         
            -
                task :install_gems, :roles => :app do
         
     | 
| 
       17 
     | 
    
         
            -
                  run "rake gems:install -f #{release_path}/Rakefile RAILS_ENV=#{rails_env}"
         
     | 
| 
       18 
     | 
    
         
            -
                end
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
                desc <<-DESC
         
     | 
| 
       21 
     | 
    
         
            -
                  Load fixtures from db/fixtures to the database
         
     | 
| 
       22 
     | 
    
         
            -
                DESC
         
     | 
| 
       23 
     | 
    
         
            -
                task :load_fixtures, :roles => :db, :only => { :primary => true } do
         
     | 
| 
       24 
     | 
    
         
            -
                  run "rake db:fixtures:load FIXTURES_PATH=db/fixtures RAILS_ENV=#{rails_env} -f #{release_path}/Rakefile"
         
     | 
| 
       25 
     | 
    
         
            -
                end
         
     | 
| 
       26 
     | 
    
         
            -
              end
         
     | 
| 
       27 
     | 
    
         
            -
            end
         
     | 
    
        data/recipes/git.rb
    DELETED
    
    | 
         @@ -1,14 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            namespace :capone do
         
     | 
| 
       2 
     | 
    
         
            -
              namespace :git do
         
     | 
| 
       3 
     | 
    
         
            -
                desc <<-DESC
         
     | 
| 
       4 
     | 
    
         
            -
                  Creates a remote repository and adds it as origin to the local repository.
         
     | 
| 
       5 
     | 
    
         
            -
                DESC
         
     | 
| 
       6 
     | 
    
         
            -
                task :remote do
         
     | 
| 
       7 
     | 
    
         
            -
                  run "mkdir ~/git/#{application}.git && cd ~/git/#{application}.git && git --bare init"
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
                  cmd = "git remote add origin #{repository} && git push origin master"
         
     | 
| 
       10 
     | 
    
         
            -
                  puts cmd
         
     | 
| 
       11 
     | 
    
         
            -
                  `#{cmd}`
         
     | 
| 
       12 
     | 
    
         
            -
                end
         
     | 
| 
       13 
     | 
    
         
            -
              end
         
     | 
| 
       14 
     | 
    
         
            -
            end
         
     | 
    
        data/recipes/install.rb
    DELETED
    
    | 
         @@ -1,105 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            namespace :capone do
         
     | 
| 
       2 
     | 
    
         
            -
              namespace :install do
         
     | 
| 
       3 
     | 
    
         
            -
                desc <<-DESC
         
     | 
| 
       4 
     | 
    
         
            -
                  Install all software for all servers.
         
     | 
| 
       5 
     | 
    
         
            -
                DESC
         
     | 
| 
       6 
     | 
    
         
            -
                task :default do
         
     | 
| 
       7 
     | 
    
         
            -
                    update::software
         
     | 
| 
       8 
     | 
    
         
            -
                    app
         
     | 
| 
       9 
     | 
    
         
            -
                    web
         
     | 
| 
       10 
     | 
    
         
            -
                    db
         
     | 
| 
       11 
     | 
    
         
            -
                end
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
                desc <<-DESC
         
     | 
| 
       14 
     | 
    
         
            -
                  Install all software for app server.
         
     | 
| 
       15 
     | 
    
         
            -
                DESC
         
     | 
| 
       16 
     | 
    
         
            -
                task :app, :roles => :app do
         
     | 
| 
       17 
     | 
    
         
            -
                  git
         
     | 
| 
       18 
     | 
    
         
            -
                  ruby
         
     | 
| 
       19 
     | 
    
         
            -
                  rubygems
         
     | 
| 
       20 
     | 
    
         
            -
                  gems
         
     | 
| 
       21 
     | 
    
         
            -
                  mongrel
         
     | 
| 
       22 
     | 
    
         
            -
                end
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
                desc <<-DESC
         
     | 
| 
       25 
     | 
    
         
            -
                  Install all software for web server.
         
     | 
| 
       26 
     | 
    
         
            -
                DESC
         
     | 
| 
       27 
     | 
    
         
            -
                task :web, :roles => :web do
         
     | 
| 
       28 
     | 
    
         
            -
                  nginx
         
     | 
| 
       29 
     | 
    
         
            -
                end
         
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
                desc <<-DESC
         
     | 
| 
       32 
     | 
    
         
            -
                  Install all software for db server.
         
     | 
| 
       33 
     | 
    
         
            -
                DESC
         
     | 
| 
       34 
     | 
    
         
            -
                task :db, :roles => :db do
         
     | 
| 
       35 
     | 
    
         
            -
                  mysql
         
     | 
| 
       36 
     | 
    
         
            -
                end
         
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
                desc <<-DESC
         
     | 
| 
       39 
     | 
    
         
            -
                  Install Subversion.
         
     | 
| 
       40 
     | 
    
         
            -
                DESC
         
     | 
| 
       41 
     | 
    
         
            -
                task :subversion, :roles => :app do
         
     | 
| 
       42 
     | 
    
         
            -
                  sudo "aptitude install -y subversion"
         
     | 
| 
       43 
     | 
    
         
            -
                end
         
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
                desc <<-DESC
         
     | 
| 
       46 
     | 
    
         
            -
                  Install git.
         
     | 
| 
       47 
     | 
    
         
            -
                DESC
         
     | 
| 
       48 
     | 
    
         
            -
                task :git, :roles => :app do
         
     | 
| 
       49 
     | 
    
         
            -
                  sudo "aptitude install -y git-core"
         
     | 
| 
       50 
     | 
    
         
            -
                end
         
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
                desc <<-DESC
         
     | 
| 
       53 
     | 
    
         
            -
                  Install Ruby.
         
     | 
| 
       54 
     | 
    
         
            -
                DESC
         
     | 
| 
       55 
     | 
    
         
            -
                task :ruby, :roles => :app do
         
     | 
| 
       56 
     | 
    
         
            -
                  sudo "aptitude install -y ruby ruby1.8-dev irb irb1.8 rdoc rdoc1.8 libopenssl-ruby1.8 libreadline-ruby1.8"
         
     | 
| 
       57 
     | 
    
         
            -
                end
         
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
     | 
    
         
            -
                desc <<-DESC
         
     | 
| 
       60 
     | 
    
         
            -
                  Install RubyGems.
         
     | 
| 
       61 
     | 
    
         
            -
                DESC
         
     | 
| 
       62 
     | 
    
         
            -
                task :rubygems, :roles => :app do
         
     | 
| 
       63 
     | 
    
         
            -
                  sudo "aptitude install -y libgems-ruby1.8 rubygems"
         
     | 
| 
       64 
     | 
    
         
            -
                  sudo "gem update --system --no-rdoc --no-ri"
         
     | 
| 
       65 
     | 
    
         
            -
                  sudo "ln -fs /usr/bin/gem1.8 /usr/bin/gem"
         
     | 
| 
       66 
     | 
    
         
            -
                end
         
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
                desc <<-DESC
         
     | 
| 
       69 
     | 
    
         
            -
                  Install common gems.
         
     | 
| 
       70 
     | 
    
         
            -
                DESC
         
     | 
| 
       71 
     | 
    
         
            -
                task :gems, :roles => :app do
         
     | 
| 
       72 
     | 
    
         
            -
                  sudo "aptitude install -y build-essential libmysqlclient15-dev"
         
     | 
| 
       73 
     | 
    
         
            -
                  sudo "gem install rake mysql --no-rdoc --no-ri"
         
     | 
| 
       74 
     | 
    
         
            -
                end
         
     | 
| 
       75 
     | 
    
         
            -
             
     | 
| 
       76 
     | 
    
         
            -
                desc <<-DESC
         
     | 
| 
       77 
     | 
    
         
            -
                  Install Mongrel.
         
     | 
| 
       78 
     | 
    
         
            -
                DESC
         
     | 
| 
       79 
     | 
    
         
            -
                task :mongrel, :roles => :app do
         
     | 
| 
       80 
     | 
    
         
            -
                  sudo "gem install mongrel mongrel_cluster --no-rdoc --no-ri"
         
     | 
| 
       81 
     | 
    
         
            -
             
     | 
| 
       82 
     | 
    
         
            -
                  sudo "ln -sf /usr/lib/ruby/gems/1.8/gems/mongrel_cluster-1.0.5/resources/mongrel_cluster /etc/init.d/mongrel_cluster"
         
     | 
| 
       83 
     | 
    
         
            -
                  sudo "chmod +x /etc/init.d/mongrel_cluster"
         
     | 
| 
       84 
     | 
    
         
            -
                  sudo "/usr/sbin/update-rc.d mongrel_cluster defaults"
         
     | 
| 
       85 
     | 
    
         
            -
                  sudo "mkdir /etc/mongrel_cluster"
         
     | 
| 
       86 
     | 
    
         
            -
             
     | 
| 
       87 
     | 
    
         
            -
                  sudo "mkdir -p -m 750 /var/www/apps"
         
     | 
| 
       88 
     | 
    
         
            -
                  sudo "chown deploy:deploy /var/www/apps"
         
     | 
| 
       89 
     | 
    
         
            -
                end
         
     | 
| 
       90 
     | 
    
         
            -
             
     | 
| 
       91 
     | 
    
         
            -
                desc <<-DESC
         
     | 
| 
       92 
     | 
    
         
            -
                  Install nginx.
         
     | 
| 
       93 
     | 
    
         
            -
                DESC
         
     | 
| 
       94 
     | 
    
         
            -
                task :nginx, :roles => :web do
         
     | 
| 
       95 
     | 
    
         
            -
                  sudo "aptitude install -y nginx"
         
     | 
| 
       96 
     | 
    
         
            -
                end
         
     | 
| 
       97 
     | 
    
         
            -
             
     | 
| 
       98 
     | 
    
         
            -
                desc <<-DESC
         
     | 
| 
       99 
     | 
    
         
            -
                  Install MySQL.
         
     | 
| 
       100 
     | 
    
         
            -
                DESC
         
     | 
| 
       101 
     | 
    
         
            -
                task :mysql, :roles => :db do
         
     | 
| 
       102 
     | 
    
         
            -
                  sudo "aptitude install -y mysql-server"
         
     | 
| 
       103 
     | 
    
         
            -
                end
         
     | 
| 
       104 
     | 
    
         
            -
              end
         
     | 
| 
       105 
     | 
    
         
            -
            end
         
     | 
    
        data/recipes/update.rb
    DELETED
    
    | 
         @@ -1,26 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            namespace :capone do
         
     | 
| 
       2 
     | 
    
         
            -
              namespace :update do
         
     | 
| 
       3 
     | 
    
         
            -
                desc <<-DESC
         
     | 
| 
       4 
     | 
    
         
            -
                  Update all.
         
     | 
| 
       5 
     | 
    
         
            -
                DESC
         
     | 
| 
       6 
     | 
    
         
            -
                task :default do
         
     | 
| 
       7 
     | 
    
         
            -
                  software
         
     | 
| 
       8 
     | 
    
         
            -
                  gems
         
     | 
| 
       9 
     | 
    
         
            -
                end
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
                desc <<-DESC
         
     | 
| 
       12 
     | 
    
         
            -
                  Update system software.
         
     | 
| 
       13 
     | 
    
         
            -
                DESC
         
     | 
| 
       14 
     | 
    
         
            -
                task :software do
         
     | 
| 
       15 
     | 
    
         
            -
                  sudo "aptitude update"
         
     | 
| 
       16 
     | 
    
         
            -
                  sudo "aptitude safe-upgrade -y"
         
     | 
| 
       17 
     | 
    
         
            -
                end
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
                desc <<-DESC
         
     | 
| 
       20 
     | 
    
         
            -
                  Update installed gems.
         
     | 
| 
       21 
     | 
    
         
            -
                DESC
         
     | 
| 
       22 
     | 
    
         
            -
                task :gems do
         
     | 
| 
       23 
     | 
    
         
            -
                  sudo "gem update --no-rdoc --no-ri"
         
     | 
| 
       24 
     | 
    
         
            -
                end
         
     | 
| 
       25 
     | 
    
         
            -
              end
         
     | 
| 
       26 
     | 
    
         
            -
            end
         
     | 
    
        data/tasks/capone_tasks.rake
    DELETED
    
    | 
         @@ -1,17 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            desc "Init Capone"
         
     | 
| 
       2 
     | 
    
         
            -
            task :capone do
         
     | 
| 
       3 
     | 
    
         
            -
              puts "Generating configs..."
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
              files = ["Capfile", "config/deploy.rb"]
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
              for file in files do
         
     | 
| 
       8 
     | 
    
         
            -
                if File.exists? "#{RAILS_ROOT}/#{file}"
         
     | 
| 
       9 
     | 
    
         
            -
                  puts "#{RAILS_ROOT}/#{file} already exists"
         
     | 
| 
       10 
     | 
    
         
            -
                else
         
     | 
| 
       11 
     | 
    
         
            -
                  File.copy "#{RAILS_ROOT}/vendor/plugins/capone/templates/#{file}", "#{RAILS_ROOT}/#{file}"
         
     | 
| 
       12 
     | 
    
         
            -
                end
         
     | 
| 
       13 
     | 
    
         
            -
              end
         
     | 
| 
       14 
     | 
    
         
            -
            end
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
            namespace :capone do
         
     | 
| 
       17 
     | 
    
         
            -
            end
         
     | 
    
        data/templates/Capfile
    DELETED
    
    
    
        data/templates/config/deploy.rb
    DELETED
    
    | 
         @@ -1,29 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require "mongrel_cluster/recipes"
         
     | 
| 
       2 
     | 
    
         
            -
            require "capone"
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            set :application, "set your application name here"
         
     | 
| 
       5 
     | 
    
         
            -
            set :repository,  "someuser@somehost:git/#{application}.git"
         
     | 
| 
       6 
     | 
    
         
            -
            set :scm, :git
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
            set :user, "deploy"
         
     | 
| 
       9 
     | 
    
         
            -
            set :use_sudo, false
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
            set :deploy_to, "/var/www/apps/#{application}"
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
            set :mongrel_conf, "#{deploy_to}/current/config/mongrel_cluster.yml"
         
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
            set :rails_env, "production"
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
            role :app, "your app-server here"
         
     | 
| 
       18 
     | 
    
         
            -
            role :web, "your web-server here"
         
     | 
| 
       19 
     | 
    
         
            -
            role :db,  "your db-server here", :primary => true
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
            after "deploy:setup",       "capone:deploy:setup_db"
         
     | 
| 
       22 
     | 
    
         
            -
            after "deploy:update_code", "capone:deploy:install_gems"
         
     | 
| 
       23 
     | 
    
         
            -
            # after "deploy:cold",        "capone:deploy:load_fixtures"
         
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
            before "deploy:start",   "capone:nginx:enable_vhost"
         
     | 
| 
       26 
     | 
    
         
            -
            after  "deploy:stop",    "capone:nginx:disable_vhost"
         
     | 
| 
       27 
     | 
    
         
            -
            after  "deploy:restart", "capone:nginx:reload_if_config_file_changed"
         
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
            # after "deploy:symlink", "capone:whenever:update_crontab"
         
     | 
| 
         @@ -1,18 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            ---
         
     | 
| 
       2 
     | 
    
         
            -
            cwd: <%= @deploy_to %>/current
         
     | 
| 
       3 
     | 
    
         
            -
            <% if @mongrel_log_file %>
         
     | 
| 
       4 
     | 
    
         
            -
            log_file: <%= @mongrel_log_file %>
         
     | 
| 
       5 
     | 
    
         
            -
            <% end %>
         
     | 
| 
       6 
     | 
    
         
            -
            port: <%= @mongrel_port %>
         
     | 
| 
       7 
     | 
    
         
            -
            environment: <%= @mongrel_environment %>
         
     | 
| 
       8 
     | 
    
         
            -
            address: <%= @mongrel_address %>
         
     | 
| 
       9 
     | 
    
         
            -
            <% if @mongrel_pid_file %>
         
     | 
| 
       10 
     | 
    
         
            -
            pid_file: <%= @mongrel_pid_file %>
         
     | 
| 
       11 
     | 
    
         
            -
            <% end %>
         
     | 
| 
       12 
     | 
    
         
            -
            servers: <%= @mongrel_servers %>
         
     | 
| 
       13 
     | 
    
         
            -
            <% if @mongrel_user %>
         
     | 
| 
       14 
     | 
    
         
            -
            user: <%= @mongrel_user %>
         
     | 
| 
       15 
     | 
    
         
            -
            <% end %>
         
     | 
| 
       16 
     | 
    
         
            -
            <% if @mongrel_group %>
         
     | 
| 
       17 
     | 
    
         
            -
            group: <%= @mongrel_group %>
         
     | 
| 
       18 
     | 
    
         
            -
            <% end %>
         
     | 
    
        data/templates/config/monitrc
    DELETED
    
    | 
         @@ -1,57 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            set daemon  60
         
     | 
| 
       2 
     | 
    
         
            -
            set logfile syslog facility log_daemon
         
     | 
| 
       3 
     | 
    
         
            -
            set mailserver localhost
         
     | 
| 
       4 
     | 
    
         
            -
            set mail-format { from: monit@localhost }
         
     | 
| 
       5 
     | 
    
         
            -
            set alert root@localhost
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
            check process sshd with pidfile /var/run/sshd.pid
         
     | 
| 
       8 
     | 
    
         
            -
               start program  "/etc/init.d/ssh start"
         
     | 
| 
       9 
     | 
    
         
            -
               stop program  "/etc/init.d/ssh stop"
         
     | 
| 
       10 
     | 
    
         
            -
               if failed port 22 protocol ssh then restart
         
     | 
| 
       11 
     | 
    
         
            -
               if 5 restarts within 5 cycles then timeout
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
            check process mysql with pidfile /var/run/mysqld/mysqld.pid
         
     | 
| 
       14 
     | 
    
         
            -
               group database
         
     | 
| 
       15 
     | 
    
         
            -
               start program = "/etc/init.d/mysql start"
         
     | 
| 
       16 
     | 
    
         
            -
               stop program = "/etc/init.d/mysql stop"
         
     | 
| 
       17 
     | 
    
         
            -
               if failed host 127.0.0.1 port 3306 then restart
         
     | 
| 
       18 
     | 
    
         
            -
               if 5 restarts within 5 cycles then timeout
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
            check process httpd with pidfile /usr/local/apache2/logs/httpd.pid
         
     | 
| 
       21 
     | 
    
         
            -
               group www-data
         
     | 
| 
       22 
     | 
    
         
            -
               start program  "/usr/local/apache2/bin/apachectl start"
         
     | 
| 
       23 
     | 
    
         
            -
               stop program  "/usr/local/apache2/bin/apachectl stop"
         
     | 
| 
       24 
     | 
    
         
            -
               if failed host localhost port 80 protocol http
         
     | 
| 
       25 
     | 
    
         
            -
                  and request "/" then alert
         
     | 
| 
       26 
     | 
    
         
            -
               if cpu is greater than 60% for 2 cycles then alert
         
     | 
| 
       27 
     | 
    
         
            -
               if cpu > 80% for 5 cycles then restart
         
     | 
| 
       28 
     | 
    
         
            -
               if children > 250 then restart
         
     | 
| 
       29 
     | 
    
         
            -
               if loadavg(5min) greater than 10 for 8 cycles then alert
         
     | 
| 
       30 
     | 
    
         
            -
               if 3 restarts within 5 cycles then timeout
         
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
            check process mongrel_8000 with pidfile /var/rails/MYAPP/log/mongrel.8000.pid
         
     | 
| 
       33 
     | 
    
         
            -
               group root
         
     | 
| 
       34 
     | 
    
         
            -
               if failed host 127.0.0.1 port 8000 protocol http
         
     | 
| 
       35 
     | 
    
         
            -
                  and request "/" then alert
         
     | 
| 
       36 
     | 
    
         
            -
               if cpu is greater than 60% for 2 cycles then alert
         
     | 
| 
       37 
     | 
    
         
            -
               if cpu > 80% for 5 cycles then restart
         
     | 
| 
       38 
     | 
    
         
            -
               if loadavg(5min) greater than 10 for 8 cycles then restart
         
     | 
| 
       39 
     | 
    
         
            -
               if 3 restarts within 5 cycles then timeout
         
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
       41 
     | 
    
         
            -
            check process mongrel_8001 with pidfile /var/rails/MYAPP/log/mongrel.8001.pid
         
     | 
| 
       42 
     | 
    
         
            -
               group root
         
     | 
| 
       43 
     | 
    
         
            -
               if failed host 127.0.0.1 port 8001 protocol http
         
     | 
| 
       44 
     | 
    
         
            -
                  and request "/" then alert
         
     | 
| 
       45 
     | 
    
         
            -
               if cpu is greater than 60% for 2 cycles then alert
         
     | 
| 
       46 
     | 
    
         
            -
               if cpu > 80% for 5 cycles then alert
         
     | 
| 
       47 
     | 
    
         
            -
               if loadavg(5min) greater than 10 for 8 cycles then alert
         
     | 
| 
       48 
     | 
    
         
            -
               if 3 restarts within 5 cycles then timeout
         
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
            check process postfix with pidfile /var/spool/postfix/pid/master.pid
         
     | 
| 
       51 
     | 
    
         
            -
               group mail
         
     | 
| 
       52 
     | 
    
         
            -
               start program = "/etc/init.d/postfix start"
         
     | 
| 
       53 
     | 
    
         
            -
               stop  program = "/etc/init.d/postfix stop"
         
     | 
| 
       54 
     | 
    
         
            -
               if failed port 25 protocol smtp then restart
         
     | 
| 
       55 
     | 
    
         
            -
               if 5 restarts within 5 cycles then timeout
         
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
       57 
     | 
    
         
            -
             
     | 
    
        data/templates/system/nginx.conf
    DELETED
    
    | 
         @@ -1,58 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # User and group to run as
         
     | 
| 
       2 
     | 
    
         
            -
            user www-data;
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            # Number of nginx worker processes
         
     | 
| 
       5 
     | 
    
         
            -
            worker_processes 4;
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
            # Path to main error log file
         
     | 
| 
       8 
     | 
    
         
            -
            error_log /var/log/nginx/error.log;
         
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
            # Path to the pid-file
         
     | 
| 
       11 
     | 
    
         
            -
            pid /var/run/nginx.pid;
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
            events {
         
     | 
| 
       14 
     | 
    
         
            -
                # max_clients = worker_processes * worker_connections
         
     | 
| 
       15 
     | 
    
         
            -
                worker_connections 1024;
         
     | 
| 
       16 
     | 
    
         
            -
            }
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
            http {
         
     | 
| 
       19 
     | 
    
         
            -
                # Include mime types config file
         
     | 
| 
       20 
     | 
    
         
            -
                include /etc/nginx/mime.types;
         
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
                # Assigns the default MIME-type to be used for files where
         
     | 
| 
       23 
     | 
    
         
            -
                # the standard MIME map doesn't specify anything
         
     | 
| 
       24 
     | 
    
         
            -
                default_type application/octet-stream;
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
                # Define log format for access log
         
     | 
| 
       27 
     | 
    
         
            -
                log_format main '$remote_addr - $remote_user [$time_local] '
         
     | 
| 
       28 
     | 
    
         
            -
                                '"$request" $status $body_bytes_sent "$http_referer" '
         
     | 
| 
       29 
     | 
    
         
            -
                                '"$http_user_agent" "$http_x_forwarded_for"';
         
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
                # Assigns path, format and size of access log file
         
     | 
| 
       32 
     | 
    
         
            -
                access_log /var/log/nginx/access.log main;
         
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
                # Activate the usage of sendfile()
         
     | 
| 
       35 
     | 
    
         
            -
                sendfile on;
         
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
                # tcp_nodelay on;
         
     | 
| 
       38 
     | 
    
         
            -
                # tcp_nopush on;
         
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
                # Set the timeout for keep-alive connections with the client
         
     | 
| 
       41 
     | 
    
         
            -
                keepalive_timeout 75;
         
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
                # Enable gzip compression
         
     | 
| 
       44 
     | 
    
         
            -
                gzip on;
         
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
                # The compression level, between 1 and 9, where 1 is the least
         
     | 
| 
       47 
     | 
    
         
            -
                # compression (fastest) and 9 is the most (slowest).
         
     | 
| 
       48 
     | 
    
         
            -
                gzip_comp_level 1;
         
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
                # Enable compression for all proxy requests
         
     | 
| 
       51 
     | 
    
         
            -
                gzip_proxied any;
         
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
       53 
     | 
    
         
            -
                # Enable compression for additional MIME-types
         
     | 
| 
       54 
     | 
    
         
            -
                gzip_types text/plain text/html text/css text/javascript application/x-javascript text/xml application/xml application/xml+rss;
         
     | 
| 
       55 
     | 
    
         
            -
             
     | 
| 
       56 
     | 
    
         
            -
                # Include all virtaul hosts configurations
         
     | 
| 
       57 
     | 
    
         
            -
                include /etc/nginx/sites-enabled/*;
         
     | 
| 
       58 
     | 
    
         
            -
            }
         
     |