Commit 080593c76585bd1f45418e654842a6784728b246
1 parent
bf00a0de
Exists in
colab
and in
4 other branches
Capistrano 3 installed
Showing
5 changed files
with
133 additions
and
51 deletions
Show diff stats
Capfile
1 | -load 'deploy' | ||
2 | -load 'deploy/assets' | ||
3 | -load 'config/deploy' # remove this line to skip loading any of the default tasks | ||
4 | \ No newline at end of file | 1 | \ No newline at end of file |
2 | +# Load DSL and Setup Up Stages | ||
3 | +require 'capistrano/setup' | ||
4 | + | ||
5 | +# Includes default deployment tasks | ||
6 | +require 'capistrano/deploy' | ||
7 | + | ||
8 | +# Includes tasks from other gems included in your Gemfile | ||
9 | +# | ||
10 | +# For documentation on these, see for example: | ||
11 | +# | ||
12 | +# https://github.com/capistrano/rvm | ||
13 | +# https://github.com/capistrano/rbenv | ||
14 | +# https://github.com/capistrano/chruby | ||
15 | +# https://github.com/capistrano/bundler | ||
16 | +# https://github.com/capistrano/rails/tree/master/assets | ||
17 | +# https://github.com/capistrano/rails/tree/master/migrations | ||
18 | +# | ||
19 | +require 'capistrano/rvm' | ||
20 | +# require 'capistrano/rbenv' | ||
21 | +# require 'capistrano/chruby' | ||
22 | +require 'capistrano/bundler' | ||
23 | +require 'capistrano/rails/assets' | ||
24 | +require 'capistrano/rails/migrations' | ||
25 | + | ||
26 | +# Loads custom tasks from `lib/capistrano/tasks' if you have any defined. | ||
27 | +Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r } |
Gemfile
@@ -75,8 +75,10 @@ group :development, :test do | @@ -75,8 +75,10 @@ group :development, :test do | ||
75 | gem 'factory_girl_rails', '~> 4.3.0' | 75 | gem 'factory_girl_rails', '~> 4.3.0' |
76 | 76 | ||
77 | # Deployment | 77 | # Deployment |
78 | - gem 'capistrano', "~>2.15.5" | ||
79 | - gem 'rvm-capistrano' | 78 | + gem 'capistrano', "~>3.0.1", require: false |
79 | + gem 'capistrano-rails' | ||
80 | + gem 'capistrano-bundler' | ||
81 | + gem 'capistrano-rvm' | ||
80 | 82 | ||
81 | # JavaScript unit tests | 83 | # JavaScript unit tests |
82 | gem "konacha", "~> 3.0.0" | 84 | gem "konacha", "~> 3.0.0" |
Gemfile.lock
@@ -32,12 +32,19 @@ GEM | @@ -32,12 +32,19 @@ GEM | ||
32 | atomic (1.1.14) | 32 | atomic (1.1.14) |
33 | bcrypt-ruby (3.1.2) | 33 | bcrypt-ruby (3.1.2) |
34 | builder (3.1.4) | 34 | builder (3.1.4) |
35 | - capistrano (2.15.5) | ||
36 | - highline | ||
37 | - net-scp (>= 1.0.0) | ||
38 | - net-sftp (>= 2.0.0) | ||
39 | - net-ssh (>= 2.0.14) | ||
40 | - net-ssh-gateway (>= 1.1.0) | 35 | + capistrano (3.0.1) |
36 | + i18n | ||
37 | + rake (>= 10.0.0) | ||
38 | + sshkit (>= 0.0.23) | ||
39 | + capistrano-bundler (1.1.1) | ||
40 | + capistrano (~> 3.0) | ||
41 | + sshkit (>= 1.2.0) | ||
42 | + capistrano-rails (1.1.0) | ||
43 | + capistrano (>= 3.0.0) | ||
44 | + capistrano-bundler (>= 1.0.0) | ||
45 | + capistrano-rvm (0.1.0) | ||
46 | + capistrano (~> 3.0) | ||
47 | + sshkit (~> 1.2.0) | ||
41 | capybara (2.1.0) | 48 | capybara (2.1.0) |
42 | mime-types (>= 1.16) | 49 | mime-types (>= 1.16) |
43 | nokogiri (>= 1.3.3) | 50 | nokogiri (>= 1.3.3) |
@@ -92,7 +99,6 @@ GEM | @@ -92,7 +99,6 @@ GEM | ||
92 | rmagick | 99 | rmagick |
93 | gyoku (1.1.0) | 100 | gyoku (1.1.0) |
94 | builder (>= 2.1.2) | 101 | builder (>= 2.1.2) |
95 | - highline (1.6.20) | ||
96 | hike (1.2.3) | 102 | hike (1.2.3) |
97 | httpi (2.1.0) | 103 | httpi (2.1.0) |
98 | rack | 104 | rack |
@@ -131,11 +137,7 @@ GEM | @@ -131,11 +137,7 @@ GEM | ||
131 | multi_test (0.0.2) | 137 | multi_test (0.0.2) |
132 | net-scp (1.1.2) | 138 | net-scp (1.1.2) |
133 | net-ssh (>= 2.6.5) | 139 | net-ssh (>= 2.6.5) |
134 | - net-sftp (2.1.2) | ||
135 | - net-ssh (>= 2.6.5) | ||
136 | net-ssh (2.7.0) | 140 | net-ssh (2.7.0) |
137 | - net-ssh-gateway (1.2.0) | ||
138 | - net-ssh (>= 2.6.5) | ||
139 | nokogiri (1.6.0) | 141 | nokogiri (1.6.0) |
140 | mini_portile (~> 0.5.0) | 142 | mini_portile (~> 0.5.0) |
141 | nori-ng-1.6 (2.3.0) | 143 | nori-ng-1.6 (2.3.0) |
@@ -182,8 +184,6 @@ GEM | @@ -182,8 +184,6 @@ GEM | ||
182 | rspec-expectations (~> 2.14.0) | 184 | rspec-expectations (~> 2.14.0) |
183 | rspec-mocks (~> 2.14.0) | 185 | rspec-mocks (~> 2.14.0) |
184 | rubyntlm (0.3.4) | 186 | rubyntlm (0.3.4) |
185 | - rvm-capistrano (1.5.1) | ||
186 | - capistrano (~> 2.15.4) | ||
187 | sass (3.2.12) | 187 | sass (3.2.12) |
188 | sass-rails (4.0.1) | 188 | sass-rails (4.0.1) |
189 | railties (>= 4.0.0, < 5.0) | 189 | railties (>= 4.0.0, < 5.0) |
@@ -217,6 +217,10 @@ GEM | @@ -217,6 +217,10 @@ GEM | ||
217 | activesupport (>= 3.0) | 217 | activesupport (>= 3.0) |
218 | sprockets (~> 2.8) | 218 | sprockets (~> 2.8) |
219 | sqlite3 (1.3.8) | 219 | sqlite3 (1.3.8) |
220 | + sshkit (1.2.0) | ||
221 | + net-scp (>= 1.1.2) | ||
222 | + net-ssh | ||
223 | + term-ansicolor | ||
220 | term-ansicolor (1.2.2) | 224 | term-ansicolor (1.2.2) |
221 | tins (~> 0.8) | 225 | tins (~> 0.8) |
222 | therubyracer (0.12.0) | 226 | therubyracer (0.12.0) |
@@ -254,7 +258,10 @@ PLATFORMS | @@ -254,7 +258,10 @@ PLATFORMS | ||
254 | ruby | 258 | ruby |
255 | 259 | ||
256 | DEPENDENCIES | 260 | DEPENDENCIES |
257 | - capistrano (~> 2.15.5) | 261 | + capistrano (~> 3.0.1) |
262 | + capistrano-bundler | ||
263 | + capistrano-rails | ||
264 | + capistrano-rvm | ||
258 | coffee-rails (~> 4.0.0) | 265 | coffee-rails (~> 4.0.0) |
259 | coveralls | 266 | coveralls |
260 | cucumber (~> 1.3.10) | 267 | cucumber (~> 1.3.10) |
@@ -274,7 +281,6 @@ DEPENDENCIES | @@ -274,7 +281,6 @@ DEPENDENCIES | ||
274 | poltergeist (~> 1.4.0) | 281 | poltergeist (~> 1.4.0) |
275 | rails (= 4.0.1) | 282 | rails (= 4.0.1) |
276 | rspec-rails | 283 | rspec-rails |
277 | - rvm-capistrano | ||
278 | sass-rails (~> 4.0.0.rc2) | 284 | sass-rails (~> 4.0.0.rc2) |
279 | sdoc | 285 | sdoc |
280 | shoulda-matchers | 286 | shoulda-matchers |
config/deploy.rb
1 | -require "rvm/capistrano" | ||
2 | -require 'bundler/capistrano' | 1 | +set :application, 'mezuro' |
2 | +set :repo_url, 'https://github.com/mezuro/mezuro.git' | ||
3 | 3 | ||
4 | -set :default_shell, "/bin/bash -l" | ||
5 | -set :rails_env, "production" | 4 | +# ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp } |
6 | 5 | ||
7 | -set :rvm_ruby_string, :local # use the same ruby as used locally for deployment | ||
8 | -set :rvm_autolibs_flag, "read-only" # more info: rvm help autolibs | ||
9 | -set :rvm_type, :user | ||
10 | - | ||
11 | -set :application, "mezuro" | ||
12 | set :deploy_to, "/home/mezuro/app" | 6 | set :deploy_to, "/home/mezuro/app" |
13 | -set :repository, "https://github.com/mezuro/mezuro.git" | 7 | +# set :scm, :git |
14 | 8 | ||
15 | -set :user, 'mezuro' | ||
16 | -set :use_sudo, false | ||
17 | -set :rvm_install_with_sudo, true | ||
18 | -default_run_options[:pty] = true | 9 | +# set :format, :pretty |
10 | +# set :log_level, :debug | ||
11 | +# set :pty, true | ||
19 | 12 | ||
20 | -# set :scm, :git # You can set :scm explicitly or Capistrano will make an intelligent guess based on known version control directory names | ||
21 | -# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none` | 13 | +# set :linked_files, %w{config/database.yml} |
14 | +# set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system} | ||
22 | 15 | ||
23 | -role :web, "mezuro.org" # Your HTTP server, Apache/etc | ||
24 | -role :app, "mezuro.org" # This may be the same as your `Web` server | ||
25 | -role :db, "mezuro.org", :primary => true # This is where Rails migrations will run | 16 | +# set :default_env, { path: "/opt/ruby/bin:$PATH" } |
17 | +# set :keep_releases, 5 | ||
26 | 18 | ||
27 | -# before 'deploy:setup', 'rvm:install_rvm' # install RVM | ||
28 | -before 'deploy:setup', 'rvm:install_ruby' # install Ruby and create gemset, OR: | ||
29 | -before 'deploy:setup', 'rvm:create_gemset' # only create gemset | ||
30 | -after 'deploy:assets:symlink', 'deploy:config_symlinks' | ||
31 | -after 'deploy:restart', "deploy:cleanup" | 19 | +# User info |
20 | +set :user, 'mezuro' | ||
21 | + | ||
22 | +# RVM | ||
23 | +set :rvm_ruby_string, :local # use the same ruby as used locally for deployment | ||
24 | +set :rvm_autolibs_flag, "read-only" # more info: rvm help autolibs | ||
25 | +set :rvm_type, :user | ||
26 | +set :rvm_install_with_sudo, true | ||
32 | 27 | ||
33 | namespace :deploy do | 28 | namespace :deploy do |
34 | - task :start do ; end | ||
35 | 29 | ||
36 | - task :stop do ; end | 30 | + desc 'Restart application' |
31 | + task :restart do | ||
32 | + on roles(:app), in: :sequence, wait: 5 do | ||
33 | + execute "touch #{File.join(current_path,'tmp','restart.txt')}" | ||
34 | + end | ||
35 | + end | ||
37 | 36 | ||
38 | - task :restart, :roles => :app, :except => { :no_release => true } do | ||
39 | - run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}" | 37 | + after :restart, :clear_cache do |
38 | + on roles(:web), in: :groups, limit: 3, wait: 10 do | ||
39 | + # Here we can do anything such as: | ||
40 | + # within release_path do | ||
41 | + # execute :rake, 'cache:clear' | ||
42 | + # end | ||
43 | + end | ||
40 | end | 44 | end |
41 | 45 | ||
42 | - task :config_symlinks do | ||
43 | - run "ln -s #{File.join(deploy_to, 'shared', 'config/database.yml')} #{File.join(release_path, 'config/database.yml')}" | 46 | + before :compile_assets, :config_symlinks do |
47 | + on roles(:web) do | ||
48 | + execute "ln -s #{File.join(deploy_to, 'shared', 'config/database.yml')} #{File.join(release_path, 'config/database.yml')}" | ||
49 | + end | ||
44 | end | 50 | end |
45 | -end | ||
46 | \ No newline at end of file | 51 | \ No newline at end of file |
52 | + | ||
53 | + after :finishing, 'deploy:cleanup' | ||
54 | + | ||
55 | +end |
@@ -0,0 +1,42 @@ | @@ -0,0 +1,42 @@ | ||
1 | +set :stage, :production | ||
2 | + | ||
3 | +# Simple Role Syntax | ||
4 | +# ================== | ||
5 | +# Supports bulk-adding hosts to roles, the primary | ||
6 | +# server in each group is considered to be the first | ||
7 | +# unless any hosts have the primary property set. | ||
8 | +#role :app, %w{mezuro.org} | ||
9 | +#role :web, %w{mezuro.org} | ||
10 | +#role :db, %w{mezuro.org} | ||
11 | + | ||
12 | +# Extended Server Syntax | ||
13 | +# ====================== | ||
14 | +# This can be used to drop a more detailed server | ||
15 | +# definition into the server list. The second argument | ||
16 | +# something that quacks like a hash can be used to set | ||
17 | +# extended properties on the server. | ||
18 | +server 'mezuro.org', user: 'mezuro', roles: %w{web app db} | ||
19 | + | ||
20 | +# you can set custom ssh options | ||
21 | +# it's possible to pass any option but you need to keep in mind that net/ssh understand limited list of options | ||
22 | +# you can see them in [net/ssh documentation](http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start) | ||
23 | +# set it globally | ||
24 | +# set :ssh_options, { | ||
25 | +# keys: %w(/home/rlisowski/.ssh/id_rsa), | ||
26 | +# forward_agent: false, | ||
27 | +# auth_methods: %w(password) | ||
28 | +# } | ||
29 | +# and/or per server | ||
30 | +# server 'example.com', | ||
31 | +# user: 'user_name', | ||
32 | +# roles: %w{web app}, | ||
33 | +# ssh_options: { | ||
34 | +# user: 'user_name', # overrides user setting above | ||
35 | +# keys: %w(/home/user_name/.ssh/id_rsa), | ||
36 | +# forward_agent: false, | ||
37 | +# auth_methods: %w(publickey password) | ||
38 | +# # password: 'please use keys' | ||
39 | +# } | ||
40 | +# setting per server overrides global ssh_options | ||
41 | + | ||
42 | +# fetch(:default_env).merge!(rails_env: :production) |