capistrano-af83 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT LICENSE
2
+
3
+ Copyright (c) af83
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,70 @@
1
+ Capistrano recipes for af83
2
+ ===========================
3
+
4
+ We are [af83](http://dev.af83.com/). We develop web applications and most of
5
+ them are deployed with [capistrano](https://github.com/capistrano/capistrano).
6
+ The capistrano-af83 gem let us share recipes and good practices between our
7
+ projects. It's an Open-Source project, so feel free to use it or just look at
8
+ it for inspiration!
9
+
10
+
11
+ How to use it?
12
+ --------------
13
+
14
+ Add it in the `Gemfile` and run `bundle update`:
15
+
16
+ ```ruby
17
+ group :development do
18
+ gem 'capistrano-af83'
19
+ end
20
+ ```
21
+
22
+ Then use of one the
23
+ [examples](https://github.com/af83/capistrano-af83/blob/master/examples) of
24
+ `config/deploy.rb` files and follow the comments for configuration.
25
+
26
+ And finally test it on the dev environment:
27
+
28
+ ```sh
29
+ cap dev deploy:setup
30
+ cap dev deploy:check
31
+ cap dev deploy
32
+ ```
33
+
34
+
35
+ Capistrano extensions
36
+ ---------------------
37
+
38
+ We use some capistrano extensions (capistrano-af83 depends on them):
39
+
40
+ - [**multistage**](https://github.com/TechnoGate/capistrano-exts):
41
+ have a configuration per environment
42
+ - [**capistrano_colors**](https://github.com/stjernstrom/capistrano_colors/):
43
+ colorize your capistrano output for better overview
44
+ - [**capistrano-notification**](https://github.com/ursm/capistrano-notification):
45
+ notify the end of the deployment on IRC
46
+ - [**sushi**](https://github.com/presskey/sushi):
47
+ add a recipe that starts a SSH connection to remote server
48
+ - [**bundler**](http://gembundler.com/deploying.html):
49
+ automatically run bundle install on the remote server with deployment-friendly options
50
+
51
+
52
+ Environments
53
+ ------------
54
+
55
+ +-----------+-------------+------------+----------------------------+
56
+ | Cap stage | Rails env | Git branch | Host |
57
+ +-----------+-------------+------------+----------------------------+
58
+ | N/A | development | master | localhost |
59
+ | N/A | test | master | localhost/jenkins |
60
+ | dev | dev | master | dev.{project}.af83.com |
61
+ | staging | staging | staging | staging.{project}.af83.com |
62
+ | prod | production | production | {project}.com |
63
+ +-----------+-------------+------------+----------------------------+
64
+
65
+
66
+ Credits
67
+ -------
68
+
69
+ Copyright (c) 2011 af83
70
+ Released under the MIT license
@@ -0,0 +1,7 @@
1
+ # This is our default stack
2
+
3
+ require "capistrano"
4
+ Capistrano::Configuration.instance.load_paths << File.dirname(__FILE__)
5
+ Capistrano::Configuration.instance.load "af83/default"
6
+ Capistrano::Configuration.instance.load "af83/environments"
7
+ require "capistrano/af83/extensions"
@@ -0,0 +1,19 @@
1
+ # Use a custom maintenance page
2
+
3
+ # TODO explain how to use it
4
+
5
+ namespace :deploy do
6
+ namespace :web do
7
+ task :disable, :roles => :web, :except => { :no_release => true } do
8
+ on_rollback { run "rm #{shared_path}/system/maintenance.html" }
9
+ require 'erb'
10
+ reason, deadline = ENV['REASON'], ENV['deadline']
11
+ template = File.read(File.join(File.dirname(__FILE__), "templates", "maintenance.rhtml"))
12
+ result = ERB.new(template).result(binding)
13
+ put result, "#{shared_path}/system/maintenance.html", :mode => 0644
14
+ end
15
+ end
16
+ end
17
+
18
+ before "deploy:cold", "deploy:web:disable"
19
+ after "deploy:cold", "deploy:web:enable"
@@ -0,0 +1,23 @@
1
+ # Set default values
2
+
3
+ default_run_options[:pty] = true
4
+
5
+ # Obviously, we are git lovers
6
+ depend :remote, :command, "git"
7
+ set :scm, :git
8
+ set :scm_username, :af83
9
+ set :repository, "#{scm_username}@git.af83.com:#{appname}.git"
10
+
11
+ set :use_sudo, false
12
+ set :deploy_via, :remote_cache
13
+ set (:application) { "#{rails_env}.#{appname}.af83.com" }
14
+ set (:deploy_to) { "/var/www/#{user}/#{rails_env}" }
15
+
16
+ # I don't know why capistrano don't do the cleanup by default,
17
+ # but it should be the case.
18
+ set :keep_releases, 5
19
+ after "deploy:symlink", "deploy:cleanup"
20
+
21
+ # TODO move this somewhere else
22
+ depend :remote, :command, "bundle"
23
+ set :bundle_cmd, "bundle"
@@ -0,0 +1,6 @@
1
+ # Configure the 3 stages: dev, staging and production
2
+
3
+ set :stages, %w(dev staging production)
4
+ set :default_stage, "dev"
5
+
6
+ # TODO find how to provide default values for branch, rails_env per stage
@@ -0,0 +1,17 @@
1
+ # Add a recipe for Elastic Search
2
+
3
+ namespace :es do
4
+ desc "Start Elastic Search if needed"
5
+ task :start do
6
+ run "cd #{release_path} && #{bundle_cmd} exec rake es:soft_start", :once => true
7
+ end
8
+
9
+ task :restart do
10
+ run "cd #{release_path} && #{bundle_cmd} exec rake es:running_restart", :once => true
11
+ end
12
+
13
+ desc "Recreate index and reindex last records for ES/Tire models"
14
+ task :rebuild_index do
15
+ run "cd #{current_path} && #{bundle_cmd} exec rake es:rebuild_index", :once => true
16
+ end
17
+ end
@@ -0,0 +1,6 @@
1
+ # Load the capistrano extensions
2
+ require "capistrano_colors"
3
+ require "capistrano-notification"
4
+ require "capistrano/ext/multistage"
5
+ require "sushi/ssh"
6
+ require "bundler/capistrano"
@@ -0,0 +1,14 @@
1
+ # Add the info task
2
+
3
+ desc 'prints the configuration'
4
+ task :info do
5
+ show = Proc.new {|var| puts "\t- #{var}: #{fetch var}\n\n" }
6
+ show.call "stage"
7
+ show.call "user"
8
+ show.call "appname"
9
+ show.call "application"
10
+ show.call "deploy_to"
11
+ show.call "repository"
12
+ show.call "branch"
13
+ show.call "rails_env"
14
+ end
@@ -0,0 +1,10 @@
1
+ # Create a JS file with the Rails routes
2
+
3
+ namespace :js do
4
+ desc "Create js routes"
5
+ task :create_routes do
6
+ run "cd #{release_path} && #{bundle_cmd} exec rake js:routes"
7
+ end
8
+ end
9
+
10
+ after "deploy:update_code", "js:create_routes"
@@ -0,0 +1,22 @@
1
+ # Use the config/mongoid/#{rails_env}.yml file for mongoid config
2
+
3
+ namespace :mongoid do
4
+ desc "Copy mongoid config"
5
+ task :copy do
6
+ upload "config/mongoid/#{rails_env}.yml", "#{shared_path}/mongoid.yml", :via => :scp, :once => true
7
+ end
8
+
9
+ desc "Link the mongoid config in the release_path"
10
+ task :symlink do
11
+ run "ln -s #{shared_path}/mongoid.yml #{release_path}/config/mongoid.yml", :once => true
12
+ end
13
+
14
+ desc "Create MongoDB indexes"
15
+ task :index do
16
+ run "cd #{current_path} && #{bundle_cmd} exec rake db:mongoid:create_indexes", :once => true
17
+ end
18
+ end
19
+
20
+ after "deploy:finalize_update", "mongoid:copy"
21
+ after "deploy:finalize_update", "mongoid:symlink"
22
+ after "deploy:update_code", "mongoid:index"
@@ -0,0 +1,20 @@
1
+ # Add a recipe for resque
2
+
3
+ namespace :resque do
4
+ desc "start resque queues"
5
+ task :start do
6
+ run "cd #{current_path} && #{bundle_cmd_cmd} exec rake resque:pool:start", :once => true
7
+ end
8
+
9
+ desc "stop resque queues"
10
+ task :stop do
11
+ run "cd #{current_path} && #{bundle_cmd_cmd} exec rake resque:pool:stop", :once => true
12
+ end
13
+
14
+ desc "restart resque queues"
15
+ task :restart do
16
+ run "cd #{current_path} && #{bundle_cmd_cmd} exec rake resque:pool:stop && sleep 1 && #{bundle} exec rake resque:pool:start", :once => true
17
+ end
18
+ end
19
+
20
+ after 'deploy:update_code', 'resque:restart'
@@ -0,0 +1,15 @@
1
+ # Use thin for deployment
2
+
3
+ namespace :deploy do
4
+ task :start, :roles => :app do
5
+ run "cd #{current_path} && #{bundle_cmd} exec thin start -C #{shared_path}/thin.yml"
6
+ end
7
+
8
+ task :stop, :rules => :app do
9
+ run "cd #{current_path} && #{bundle_cmd} exec thin stop -C #{shared_path}/thin.yml"
10
+ end
11
+
12
+ task :restart, :roles => :app, :except => { :no_release => true } do
13
+ run "cd #{current_path} && #{bundle_cmd} exec thin restart -C #{shared_path}/thin.yml"
14
+ end
15
+ end
@@ -0,0 +1,19 @@
1
+ # Use unicorn for deployment
2
+
3
+ namespace :deploy do
4
+ task :start, :roles => :app do
5
+ run "cd #{current_path} && #{bundle_cmd} exec unicorn -c config/unicorn.rb -E #{rails_env} -D"
6
+ end
7
+
8
+ task :stop, :roles => :app do
9
+ set :unicorn_pidfile, "#{shared_path}/pids/unicorn.pid"
10
+ run "if [ -e #{unicorn_pidfile} ] ; then kill -QUIT `cat #{unicorn_pidfile}` ; fi"
11
+ end
12
+
13
+ task :restart, :roles => :app do
14
+ set :unicorn_pid, capture("cat #{shared_path}/pids/unicorn.pid").chomp
15
+ run "kill -USR2 #{unicorn_pid}"
16
+ sleep 1
17
+ run "kill -QUIT #{unicorn_pid}"
18
+ end
19
+ end
@@ -0,0 +1,5 @@
1
+ module Capistrano
2
+ module AF83
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-af83
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Bruno Michel
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-12-15 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: capistrano
16
+ requirement: &86118080 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '2.9'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *86118080
25
+ - !ruby/object:Gem::Dependency
26
+ name: capistrano-ext
27
+ requirement: &86115750 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '1.2'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *86115750
36
+ - !ruby/object:Gem::Dependency
37
+ name: capistrano_colors
38
+ requirement: &86115510 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: '0.5'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *86115510
47
+ - !ruby/object:Gem::Dependency
48
+ name: capistrano-notification
49
+ requirement: &86115150 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '0.1'
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: *86115150
58
+ - !ruby/object:Gem::Dependency
59
+ name: sushi
60
+ requirement: &86114760 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ version: 0.0.2
66
+ type: :runtime
67
+ prerelease: false
68
+ version_requirements: *86114760
69
+ description: Capistrano recipes for af83
70
+ email: bruno.michel@af83.com
71
+ executables: []
72
+ extensions: []
73
+ extra_rdoc_files: []
74
+ files:
75
+ - LICENSE
76
+ - README.md
77
+ - lib/capistrano/af83.rb
78
+ - lib/capistrano/af83/custom_maintenance_page.rb
79
+ - lib/capistrano/af83/default.rb
80
+ - lib/capistrano/af83/environments.rb
81
+ - lib/capistrano/af83/es.rb
82
+ - lib/capistrano/af83/extensions.rb
83
+ - lib/capistrano/af83/info.rb
84
+ - lib/capistrano/af83/js_routes.rb
85
+ - lib/capistrano/af83/mongoid.rb
86
+ - lib/capistrano/af83/resque.rb
87
+ - lib/capistrano/af83/thin.rb
88
+ - lib/capistrano/af83/unicorn.rb
89
+ - lib/capistrano/af83/version.rb
90
+ homepage: https://github.com/af83/capistrano-af83
91
+ licenses: []
92
+ post_install_message:
93
+ rdoc_options: []
94
+ require_paths:
95
+ - lib
96
+ required_ruby_version: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ none: false
104
+ requirements:
105
+ - - ! '>='
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ requirements: []
109
+ rubyforge_project:
110
+ rubygems_version: 1.8.12
111
+ signing_key:
112
+ specification_version: 3
113
+ summary: Capistrano recipes for af83
114
+ test_files: []
115
+ has_rdoc: