capistranovelys 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 628f0080583595564a2eb58cb92199f1a1f231f4
4
+ data.tar.gz: 70a58b456f97e0626142ee24cf082c1f6828f0a9
5
+ SHA512:
6
+ metadata.gz: c0c5e93a2074a4f1d609ffd4daebb17d1646fbb6997d9ea74444a70ac4dfdcef762e332b7cc439c827622f392dbcdefa4d343f2a8a3e0288bb1fd341bcfe89bf
7
+ data.tar.gz: ac39207f4ee54fe9dcacf47da12932010af9d98050f02bf4cc19241d77f28ab437c13bcf4738ffbf32e2c7ccba0e68a9fe4256707f4957330871ae6a6f74023c
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ .bundle
2
+ Gemfile.lock
3
+ pkg
4
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENCE ADDED
File without changes
data/README.md ADDED
@@ -0,0 +1,126 @@
1
+ # Capistranovelys - Keeping our recipes DRY
2
+
3
+ This gem, once stable, should include every recipe/task that serves for more than one of our project.
4
+
5
+ ## Installation
6
+
7
+ `capistranovelys` has a dependency on recent versions of `capistrano`,
8
+ meaning you can remove `capistrano` and `capistrano-ext` from your Gemfile, and replace it with :
9
+
10
+ ```ruby
11
+ gem "capistranovelys", :git => 'git@github.com:novelys/capistranovelys.git'
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ In your deploy.rb :
17
+
18
+ * remove `require "production_chain/capistrano";
19
+ * add `require 'capistrano/novelys'` (loads the core recipes)
20
+ * load recipes you need, eg: `use_stack :database, :rails2, :rbenv, :whenever`. To be used **BEFORE** other loading of recipes such as `deploy/assets`, otherwise some hooks (such as the symlinks) will be executed too late.
21
+ * You can use `use_default_stack_and [arg, ...]`. It will load `airbrake`, `rbenv`, `unicorn`, `logs`, `stages`, `remote_commands, production_chain`, and the recipes supplied as arguments. Use `use_default_stack` if you don't want/need anything else.
22
+ * Make sure you don't have duplicates!
23
+
24
+ ## Recipes available
25
+
26
+ ### Core
27
+
28
+ Common setup and options is done here. I suggest reading the file to go through all the details.
29
+
30
+ Basically, using core means you're using git, you're using rails, and you'll keep 5 releases.
31
+
32
+ ### SSH
33
+
34
+ This gem has a dependency on `sushi`. This allows you to do `capistrano [stage] ssh`.
35
+
36
+ ### Rails (`rails`)
37
+
38
+ Rails 3 & 4 commands.
39
+
40
+ * `rails:console` : open a rails console
41
+ * `rails:secret_token:copy` : copy the secret_token from your local file to the shared path
42
+ * `rails:secret_token:symlink` : symlink the secret_token.rb file from the shared path to the current path. Hooked after `deploy:update_code`
43
+
44
+ ### Rails 2 (`rails2`)
45
+
46
+ Rails 2 commands.
47
+
48
+ * `rails2:console` : open a rails console
49
+ * `rails2:secret_token:copy` : copy the session_store from your local file to the shared path
50
+ * `rails2:secret_token:symlink` : symlink the session_store.rb file from the shared path to the current path. Hooked after `deploy:update_code`
51
+
52
+ ### Stages (`stages`)
53
+
54
+ Replacement with better defaults for stages:
55
+
56
+ * bundles two stages, `staging` and `production`, `staging` being the default`;
57
+ * those stages comes with default for `branch` and `rails_env`; staging can override `branch` at runtime (via `cap -S branch=value`);
58
+ * if no stages are specified, stages are defined and loaded by looking in `config/deploy/*.rb`
59
+
60
+ You should not require `capistrano/ext/multistage`.
61
+
62
+ ### Database (`database`)
63
+
64
+ * `database:create` : create the database
65
+ * `database:seed` : seed the database
66
+ * `database:copy` : copy the database.yml from your local file to the shared path
67
+ * `database:symlink` : symlink the database.yml file from the shared path to the current path. Hooked after `deploy:update_code`
68
+
69
+ ### Mongoid (`mongoid`)
70
+
71
+ * `mongoid:copy` : copy the mongoid.yml from your local file to the shared path
72
+ * `mongoid:symlink` : symlink the mongoid.yml file from the shared path to the current path. Hooked after `deploy:update_code`
73
+ * `mongoid:index` : create the indexes
74
+
75
+ ### Logs (`logs`)
76
+
77
+ * `logs:tail` : tail the logs of the rails app
78
+
79
+ ### Production chain (`production_chain`)
80
+
81
+ Recipes usings rake tasks from [novelys/production_chain](https://github.com/novelys/production_chain)
82
+
83
+ * `db:dump_and_restore`: restore the database from the server to your local env. Supply `FILE=mongoid` when using mongoid.
84
+ * `assets:dump_and_restore`: restore the assets from the public direction to your local env.
85
+
86
+ ### Rbenv (`rbenv`)
87
+
88
+ Setup the `default_environment` with the correct path for rbenv
89
+
90
+ ### Remote commands (`remote_commands`)
91
+
92
+ * `remote:rake` : Execute a rake task on the target (eg: `cap remote:rake "assets:precompile"`)
93
+ * `remote:command` : Execute a shell command on the target (eg: `cap remote:command ls`)
94
+
95
+ ### S3 (`s3`)
96
+
97
+ * `s3:copy` : copy the amazon_s3.yml from your local file to the shared path
98
+ * `s3:symlink` : symlink the amazon_s3.yml file from the shared path to the current path. Hooked after `deploy:update_code`
99
+
100
+ ### Unicorn (`unicorn`)
101
+
102
+ `deploy:start`, `deploy:stop`, `deploy:graceful_stop`, `deploy:reload`, `deploy:restart` tasks for unicorn
103
+
104
+ ### Puma (`puma`)
105
+
106
+ `deploy:start`, `deploy:stop`, `deploy:graceful_stop`, `deploy:reload`, `deploy:restart` tasks for puma. Doesn't actually do anything except requiring "puma".
107
+
108
+ ### Airbrake (`airbrake`)
109
+
110
+ * `airbrake:copy` : copy the airbrake.rb from your local file to the shared path
111
+ * `airbrake:symlink` : symlink the airbrake.rb file from the shared path to the current path. Hooked after `deploy:update_code`
112
+
113
+ ### Sphinx (`sphinx`)
114
+
115
+ * `thinking_sphinx:copy` : copy the *.sphinx.conf from your local file to the shared path
116
+ * `thinking_sphinx:symlink` : symlink the *.sphinx.conf file from the shared path to the current path. Hooked after `deploy:update_code`
117
+ * Every task available under the namespace `thinking_sphinx` is also available under the namespace `ts`, eg. `ts:rebuild`
118
+
119
+ ### Sunspot (`sunspot`)
120
+
121
+ * `sunspot:copy` : copy the sunspot.yml from your local file to the shared path
122
+ * `sunspot:symlink` : symlink the sunspot.yml file from the shared path to the current path. Hooked after `deploy:update_code`
123
+
124
+ ### Whenever (`whenever`)
125
+
126
+ Setup options for the `whenever` gem
@@ -0,0 +1,22 @@
1
+ # encoding: utf-8
2
+
3
+ $:.unshift File.expand_path('../lib', __FILE__)
4
+ require 'capistrano/novelys/version'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = 'capistranovelys'
8
+ s.version = Capistrano::Novelys::VERSION
9
+ s.authors = ['Kevin Soltysiak']
10
+ s.email = 'kevin.soltysiak@novelys.com'
11
+ s.homepage = 'https://github.com/novelys/capistranovelys'
12
+ s.summary = 'Capistrano recipes for novelys'
13
+ s.description = 'Capistrano recipes in use at novelys'
14
+ s.license = 'MIT'
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.platform = Gem::Platform::RUBY
18
+ s.require_path = 'lib'
19
+
20
+ s.add_dependency 'capistrano', '~> 2.15.0'
21
+ s.add_dependency 'sushi', '~> 0.0.2'
22
+ end
@@ -0,0 +1,21 @@
1
+ # This is our default stack
2
+
3
+ require "capistrano"
4
+ require "capistrano/novelys/core_extensions"
5
+ require "capistrano/novelys/version"
6
+ require "capistrano/novelys/helpers"
7
+
8
+ if Capistrano::Configuration.instance
9
+ Capistrano::Configuration.instance.load_paths << File.dirname(__FILE__)
10
+ Capistrano::Configuration.instance.load "novelys/core"
11
+
12
+ # Capistrano extensions bundled with this gem
13
+ require "sushi/ssh"
14
+
15
+ # Capistrano extensions expected to be present
16
+ begin
17
+ require "bundler/capistrano"
18
+ rescue LoadError
19
+ puts "It seems bundler is not there. This might be a problem."
20
+ end
21
+ end
@@ -0,0 +1,18 @@
1
+ require './config/boot'
2
+ require 'airbrake/capistrano'
3
+
4
+ ## Hooks
5
+ after 'deploy:update_code', 'airbrake:symlink'
6
+
7
+ ## Tasks
8
+ namespace :airbrake do
9
+ desc "Copy airbrake API Key"
10
+ task :copy do
11
+ upload "config/initializers/airbrake.rb", "#{shared_path}/config/initializers/airbrake.rb", :via => :scp
12
+ end
13
+
14
+ desc "Link the config/initializers/airbrake.rb file in the release_path"
15
+ task :symlink do
16
+ run "test -f #{release_path}/config/initializers/airbrake.rb || ln -s #{shared_path}/config/initializers/airbrake.rb #{release_path}/config/initializers/airbrake.rb"
17
+ end
18
+ end
@@ -0,0 +1,34 @@
1
+ ## Dependencies
2
+ depend :remote, :command, 'git'
3
+
4
+ ## Default configuration
5
+ set(:scm) { :git }
6
+ set(:use_sudo) { false }
7
+ set(:deploy_via) { :remote_cache }
8
+ set(:repository_cache) { 'git_cache' }
9
+ set(:copy_exclude) { %w(.svn .DS_Store .git) }
10
+ set(:keep_releases) { 5 }
11
+ set(:public_children) { %w(images) }
12
+ set(:bundle_cmd) { 'bundle' }
13
+
14
+ ## Default app configuration
15
+ set(:user) { application }
16
+ set(:deploy_to) { "/home/#{user}/www/" }
17
+ set(:github_account) { 'novelys' }
18
+ set(:repository) { "git@github.com:#{github_account}/#{application}" }
19
+
20
+ ## SSH Options
21
+ ssh_options[:forward_agent] = true
22
+ default_run_options[:pty] = true
23
+
24
+ ## Default hooks
25
+ after 'deploy:update', 'deploy:cleanup'
26
+ after 'deploy:setup', 'deploy:mkdir_config'
27
+
28
+ ## Default tasks
29
+ namespace :deploy do
30
+ desc "Create directories required for correct symlinking"
31
+ task :mkdir_config do
32
+ run "mkdir -p #{shared_path}/config/initializers"
33
+ end
34
+ end
@@ -0,0 +1,15 @@
1
+ module Capistrano
2
+ class Configuration
3
+ # Sugar for loading given recipes
4
+ def use_stack(*args)
5
+ args.each { |recipes| load "novelys/#{recipes.to_s}" }
6
+ end
7
+
8
+ # Sugar for loading common recipes (+ supplied is present)
9
+ def use_default_stack(*args)
10
+ args = ([:airbrake, :logs, :production_chain, :rbenv, :remote_commands, :stages, :unicorn] + args).uniq
11
+ use_stack(*args)
12
+ end
13
+ alias :use_default_stack_and :use_default_stack
14
+ end
15
+ end
@@ -0,0 +1,25 @@
1
+ ## Hooks
2
+ after 'deploy:update_code', 'database:symlink'
3
+
4
+ ## Tasks
5
+ namespace :database do
6
+ desc "Database create"
7
+ task :create do
8
+ run "cd #{current_path} && #{bundle_cmd} exec rake db:create:all"
9
+ end
10
+
11
+ desc "Database seeds population"
12
+ task :seed do
13
+ run "cd #{current_path} && #{bundle_cmd} exec rake db:seed"
14
+ end
15
+
16
+ desc "Copy database config"
17
+ task :copy do
18
+ upload "config/database.yml", "#{shared_path}/config/database.yml", :via => :scp
19
+ end
20
+
21
+ desc "Link the config/database.yml file in the release_path"
22
+ task :symlink do
23
+ run "test -f #{release_path}/config/database.yml || ln -s #{shared_path}/config/database.yml #{release_path}/config/database.yml"
24
+ end
25
+ end
@@ -0,0 +1,22 @@
1
+ module Capistrano
2
+ module Novelys
3
+ module Helpers
4
+ # Run rake on the server.
5
+ # To be used in tasks.
6
+ def run_remote_rake(cap, rake_cmd)
7
+ rake_args = ENV['RAKE_ARGS'].to_s.split(',')
8
+ release = cap.fetch(:latest_release)
9
+ rake = cap.fetch(:rake, 'rake')
10
+ env = cap.fetch(:rails_env, 'production')
11
+
12
+ cmd = "cd #{release} && #{rake} RAILS_ENV=#{env} #{rake_cmd}"
13
+ cmd += "['#{rake_args.join("','")}']" unless rake_args.empty?
14
+
15
+ cap.run cmd
16
+
17
+ cap.set :rakefile, nil if cap.exists?(:rakefile)
18
+ end
19
+ module_function :run_remote_rake
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,7 @@
1
+ ## Tasks
2
+ namespace :logs do
3
+ desc "Tail Rails logs"
4
+ task :tail do
5
+ stream "tail -f #{shared_path}/log/#{rails_env}.log"
6
+ end
7
+ end
@@ -0,0 +1,21 @@
1
+ ## Hooks
2
+ after 'deploy:update_code', 'mongoid:symlink'
3
+
4
+ ## Tasks
5
+ namespace :mongoid do
6
+ desc "Copy mongoid config"
7
+ task :copy do
8
+ upload "config/mongoid.yml", "#{shared_path}/config/mongoid.yml", :via => :scp
9
+ end
10
+
11
+ desc "Link the mongoid config in the release_path"
12
+ task :symlink do
13
+ run "test -f #{release_path}/config/mongoid.yml || ln -s #{shared_path}/config/mongoid.yml #{release_path}/config/mongoid.yml"
14
+ end
15
+
16
+ desc "Create MongoDB indexes"
17
+ task :index do
18
+ run "cd #{current_path} && #{bundle_cmd} exec rake db:mongoid:create_indexes", :once => true
19
+ end
20
+ end
21
+
@@ -0,0 +1,26 @@
1
+ namespace :db do
2
+ # this recipe needs the "mysql tasks" plugin
3
+ desc "Make a dump on the remote production box and restore on the local dev box"
4
+ task :dump_and_restore, :roles => :db, :only => {:primary => true} do
5
+ rake = fetch(:rake, "rake")
6
+ rails_env = fetch(:rails_env, "production")
7
+ file_env = ENV['FILE'] || "database"
8
+ run "cd #{current_release} && RAILS_ENV=#{rails_env} FILE=#{file_env} #{rake} db:backup"
9
+ get "#{current_release}/db/dump.tar.gz", "db/dump.tar.gz"
10
+ cmd = "RAILS_ENV=#{ ENV['RAILS_ENV'] || "development" } FILE=#{file_env} #{rake} db:restore"
11
+ puts cmd
12
+ system(cmd) && puts('finished')
13
+ end
14
+ end
15
+
16
+ namespace :assets do
17
+ desc "Make a dump on the remote production box and restore on the local dev box"
18
+ task :dump_and_restore, :roles => :db, :only => {:primary => true} do
19
+ assets_backup_path = "#{current_path}/system.tar.gz"
20
+ run "cd #{current_path}/ && tar czfh #{assets_backup_path} public/system/"
21
+ get "#{assets_backup_path}", "system.tar.gz"
22
+ run "cd #{current_path}/ && rm #{assets_backup_path}"
23
+ `rm -rf public/system/*`
24
+ `tar xvzf system.tar.gz`
25
+ end
26
+ end
@@ -0,0 +1 @@
1
+ require 'puma/capistrano'
@@ -0,0 +1,34 @@
1
+ require 'readline'
2
+
3
+ ## Hooks
4
+ after 'deploy:update_code', 'rails:secret_token:symlink'
5
+
6
+ ## Tasks
7
+ namespace :rails do
8
+ namespace :secret_token do
9
+ desc "Copy the secret token file to the server"
10
+ task :copy do
11
+ upload "config/initializers/secret_token.rb", "#{shared_path}/config/initializes/secret_token.rb", :via => :scp
12
+ end
13
+
14
+ desc "Symlink the secret token file in the current release"
15
+ task :symlink do
16
+ run "test -f #{release_path}/config/initializers/secret_token.rb || ln -s #{shared_path}/config/initializers/secret_token.rb #{release_path}/config/initializers/secret_token.rb"
17
+ end
18
+ end
19
+
20
+ desc "Open a Rails console"
21
+ task :console do
22
+ run_interactively "bundle exec rails console #{rails_env}"
23
+ end
24
+
25
+ desc "Open a DBConsole"
26
+ task :dbconsole do
27
+ run_interactively "bundle exec rails dbconsole #{rails_env}"
28
+ end
29
+ end
30
+
31
+ def run_interactively(command, server = nil)
32
+ server ||= find_servers_for_task(current_task).first
33
+ exec %Q(ssh #{user}@#{server.host} -t 'cd #{current_path} && #{command}')
34
+ end
@@ -0,0 +1,34 @@
1
+ require 'readline'
2
+
3
+ ## Hooks
4
+ after 'deploy:update_code', 'rails2:secret_token:symlink'
5
+
6
+ ## Tasks
7
+ namespace :rails2 do
8
+ namespace :secret_token do
9
+ desc "Copy the secret token file to the server"
10
+ task :copy do
11
+ upload "config/initializers/session_store.rb", "#{shared_path}/config/initializes/session_store.rb", :via => :scp
12
+ end
13
+
14
+ desc "Symlink the secret token file in the current release"
15
+ task :symlink do
16
+ run "test -f #{release_path}/initializers/session_store.rb || ln -s #{shared_path}/initializers/session_store.rb #{release_path}/initializers/session_store.rb"
17
+ end
18
+ end
19
+
20
+ desc "Open a Rails console"
21
+ task :console do
22
+ run_interactively "bundle exec script/console #{rails_env}"
23
+ end
24
+
25
+ desc "Open a DBConsole"
26
+ task :dbconsole do
27
+ run_interactively "bundle exec script/dbconsole #{rails_env}"
28
+ end
29
+ end
30
+
31
+ def run_interactively(command, server = nil)
32
+ server ||= find_servers_for_task(current_task).first
33
+ exec %Q(ssh #{user}@#{server.host} -t 'cd #{current_path} && #{command}')
34
+ end
@@ -0,0 +1,4 @@
1
+ # Default environment enhanced for rbenv detection
2
+ set(:default_environment) do
3
+ {'PATH' => '~/.rbenv/shims:~/.rbenv/bin:$PATH'}
4
+ end
@@ -0,0 +1,16 @@
1
+ namespace :remote do
2
+ desc 'Run remote rake task'
3
+ task :rake do
4
+ ARGV.values_at(Range.new(ARGV.index('remote:rake')+1,-1)).each do |task|
5
+ run "cd #{current_path}; RAILS_ENV=#{rails_env} bundle exec rake #{task}"
6
+ end
7
+ exit(0)
8
+ end
9
+
10
+ desc 'Run remote command'
11
+ task :command do
12
+ command = ARGV.values_at(Range.new(ARGV.index('remote:command')+1,-1))
13
+ run "cd #{current_path}; RAILS_ENV=#{rails_env} #{command*' '}"
14
+ exit(0)
15
+ end
16
+ end
@@ -0,0 +1,15 @@
1
+ ## Hooks
2
+ after 'deploy:update_code', 's3:symlink'
3
+
4
+ ## Tasks
5
+ namespace :s3 do
6
+ desc "Copy amazon S3 config"
7
+ task :copy do
8
+ upload "config/amazon_s3.yml", "#{shared_path}/config/amazon_s3.yml", :via => :scp
9
+ end
10
+
11
+ desc "Link the config/amazon_s3.yml file in the release_path"
12
+ task :symlink do
13
+ run "test -f #{release_path}/config/amazon_s3.yml || ln -s #{shared_path}/config/amazon_s3.yml #{release_path}/config/amazon_s3.yml"
14
+ end
15
+ end
@@ -0,0 +1,47 @@
1
+ # encoding: UTF-8
2
+ ## Hooks
3
+ after 'deploy:update_code', 'thinking_sphinx:symlink'
4
+
5
+ ## Tasks
6
+ namespace :thinking_sphinx do
7
+ desc "Copy local sphinx config"
8
+ task :copy do
9
+ upload "config/development.sphinx.conf", "#{shared_path}/config/#{rails_env}.sphinx.conf", :via => :scp
10
+ end
11
+
12
+ desc "Link the config/*.sphinx.conf file in the release_path"
13
+ task :symlink do
14
+ run "test -f #{release_path}/config/#{rails_env}.sphinx.conf || ln -s #{shared_path}/config/#{rails_env}.sphinx.conf #{release_path}/config/#{rails_env}.sphinx.conf"
15
+ end
16
+ end
17
+
18
+ ## Alias for thinking_sphinx namespace
19
+ namespace :ts do
20
+ desc "Generate the Sphinx configuration file"
21
+ task(:configure) { thinking_sphinx.configure }
22
+
23
+ desc "Index data"
24
+ task(:index) { thinking_sphinx.index }
25
+
26
+ desc "Stop, re-index and then start the Sphinx daemon"
27
+ task(:rebuild) { thinking_sphinx.rebuild }
28
+
29
+ desc "Stop and then start the Sphinx daemon"
30
+ task(:restart) { thinking_sphinx.restart }
31
+
32
+ desc "Add the shared folder for sphinx files for the production environment"
33
+ task(:shared_sphinx_folder) { thinking_sphinx.shared_sphinx_folder }
34
+
35
+ desc "Start the Sphinx daemon"
36
+ task(:start) { thinking_sphinx.start }
37
+
38
+ desc "Stop the Sphinx daemon"
39
+ task(:stop) { thinking_sphinx.stop }
40
+
41
+ desc "Copy local sphinx config"
42
+ task(:copy) { thinking_sphinx.copy }
43
+
44
+ desc "Link the config/*.sphinx.conf file in the release_path"
45
+ task(:symlink) { thinking_sphinx.symlink }
46
+ end
47
+
@@ -0,0 +1,52 @@
1
+ # Inspired by https://github.com/TechnoGate/capistrano-exts
2
+
3
+ set(:default_stage) { :staging }
4
+
5
+ default_stages = [default_stage, :production]
6
+ location = fetch(:stage_dir, 'config/deploy')
7
+
8
+ # Load stages from per-stage deploy file if not defined
9
+ unless exists?(:stages)
10
+ set :stages, Dir["#{location}/*.rb"].map { |f| File.basename(f, ".rb") }
11
+ end
12
+
13
+ # Force symbols
14
+ set :stages, stages.map(&:to_sym)
15
+
16
+ desc "Set the target stage to `staging'."
17
+ task :staging do
18
+ set :stage, :staging
19
+ set :branch, fetch(:branch, :staging)
20
+ set :rails_env, :staging
21
+
22
+ load "#{location}/#{stage}" if File.exists?("#{location}/#{stage}.rb")
23
+ end
24
+
25
+ desc "Set the target stage to `production'."
26
+ task :production do
27
+ set :stage, :production
28
+ set :branch, :production
29
+ set :rails_env, :production
30
+
31
+ load "#{location}/#{stage}"
32
+ end
33
+
34
+ (stages - default_stages).each do |name|
35
+ desc "Set the target stage to `#{name}'."
36
+ task(name) do
37
+ set(:stage) { name }
38
+ load "#{location}/#{stage}"
39
+ end
40
+ end
41
+
42
+ namespace :multistage do
43
+ desc "[internal] Ensure that a stage has been selected."
44
+ task :ensure do
45
+ if !exists?(:stage)
46
+ logger.important "Defaulting to `#{default_stage}'"
47
+ find_and_execute_task(default_stage)
48
+ end
49
+ end
50
+ end
51
+
52
+ on :start, "multistage:ensure", :except => default_stages + stages
@@ -0,0 +1,15 @@
1
+ ## Hooks
2
+ after 'deploy:update_code', 'sunspot:symlink'
3
+
4
+ ## Tasks
5
+ namespace :sunspot do
6
+ desc "Copy sunspot config"
7
+ task :copy do
8
+ upload "config/sunspot.yml", "#{shared_path}/config/sunspot.yml", :via => :scp
9
+ end
10
+
11
+ desc "Link the config/sunspot.yml file in the release_path"
12
+ task :symlink do
13
+ run "test -f #{release_path}/config/sunspot.yml || ln -s #{shared_path}/config/sunspot.yml #{release_path}/config/sunspot.yml"
14
+ end
15
+ end
@@ -0,0 +1,38 @@
1
+ ## Unicorn Config
2
+ set(:unicorn_binary) { 'bundle exec unicorn_rails' }
3
+ set(:unicorn_config) { "#{shared_path}/config/unicorn.rb" }
4
+ set(:unicorn_pid) { "#{current_path}/tmp/pids/unicorn.pid" }
5
+
6
+ ## Tasks
7
+ namespace :deploy do
8
+ common_options = {
9
+ :roles => :app,
10
+ :except => { :no_release => true }
11
+ }
12
+
13
+ desc "Start unicorn"
14
+ task :start, common_options do
15
+ run "cd #{current_path} && #{try_sudo} #{unicorn_binary} -c #{unicorn_config} -E #{rails_env} -D"
16
+ end
17
+
18
+ desc "Stop unicorn"
19
+ task :stop, common_options do
20
+ run "#{try_sudo} kill `cat #{unicorn_pid}`"
21
+ end
22
+
23
+ desc "Graceful stop of unicorn"
24
+ task :graceful_stop, common_options do
25
+ run "#{try_sudo} kill -s QUIT `cat #{unicorn_pid}`"
26
+ end
27
+
28
+ desc "Reload unicorn config"
29
+ task :reload, common_options do
30
+ run "#{try_sudo} kill -s USR2 `cat #{unicorn_pid}`"
31
+ end
32
+
33
+ desc "Restart unicorn"
34
+ task :restart, common_options do
35
+ stop
36
+ start
37
+ end
38
+ end
@@ -0,0 +1,5 @@
1
+ module Capistrano
2
+ module Novelys
3
+ VERSION = '1.0.0'
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ require 'whenever/capistrano'
2
+
3
+ ## Whenever
4
+ set(:whenever_command) { 'bundle exec whenever' }
5
+ set(:whenever_environment) { stage }
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistranovelys
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Kevin Soltysiak
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-01-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: capistrano
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 2.15.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 2.15.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: sushi
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.0.2
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.0.2
41
+ description: Capistrano recipes in use at novelys
42
+ email: kevin.soltysiak@novelys.com
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - ".gitignore"
48
+ - Gemfile
49
+ - LICENCE
50
+ - README.md
51
+ - capistranovelys.gemspec
52
+ - lib/capistrano/novelys.rb
53
+ - lib/capistrano/novelys/airbrake.rb
54
+ - lib/capistrano/novelys/core.rb
55
+ - lib/capistrano/novelys/core_extensions.rb
56
+ - lib/capistrano/novelys/database.rb
57
+ - lib/capistrano/novelys/helpers.rb
58
+ - lib/capistrano/novelys/logs.rb
59
+ - lib/capistrano/novelys/mongoid.rb
60
+ - lib/capistrano/novelys/production_chain.rb
61
+ - lib/capistrano/novelys/puma.rb
62
+ - lib/capistrano/novelys/rails.rb
63
+ - lib/capistrano/novelys/rails2.rb
64
+ - lib/capistrano/novelys/rbenv.rb
65
+ - lib/capistrano/novelys/remote_commands.rb
66
+ - lib/capistrano/novelys/s3.rb
67
+ - lib/capistrano/novelys/sphinx.rb
68
+ - lib/capistrano/novelys/stages.rb
69
+ - lib/capistrano/novelys/sunspot.rb
70
+ - lib/capistrano/novelys/unicorn.rb
71
+ - lib/capistrano/novelys/version.rb
72
+ - lib/capistrano/novelys/whenever.rb
73
+ homepage: https://github.com/novelys/capistranovelys
74
+ licenses:
75
+ - MIT
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.2.0
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: Capistrano recipes for novelys
97
+ test_files: []