capistrano_evrone_recipes 0.1.5 → 0.1.6

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.
@@ -7,14 +7,16 @@ Capistrano::Configuration.instance(:must_exist).load do
7
7
  default_run_options[:pty] = true
8
8
  ssh_options[:forward_agent] = true
9
9
 
10
- set :bundle_cmd, "rbenv exec bundle"
11
- set :rake, -> { "#{bundle_cmd} exec rake" }
12
- set :keep_releases, 7
13
- set :scm, "git"
14
- set :user, "deploy"
15
- set :deploy_via, :unshared_remote_cache
16
- set :copy_exclude, [".git"]
17
- set :repository_cache, -> { "#{deploy_to}/shared/#{application}.git" }
10
+ set :bundle_cmd, "rbenv exec bundle"
11
+ set :bundle_flags, "--deployment --quiet --binstubs --shebang ruby-local-exec"
12
+ set :rake, -> { "#{bundle_cmd} exec rake" }
13
+ set :keep_releases, 7
14
+ set :scm, "git"
15
+ set :user, "deploy"
16
+ set :deploy_via, :unshared_remote_cache
17
+ set :copy_exclude, [".git"]
18
+ set :repository_cache, -> { "#{deploy_to}/shared/#{application}.git" }
19
+ set :normalize_asset_timestamps, false
18
20
 
19
21
  load "deploy"
20
22
  require 'bundler/capistrano'
@@ -22,7 +24,7 @@ Capistrano::Configuration.instance(:must_exist).load do
22
24
  recipes_dir = File.dirname(File.expand_path(__FILE__))
23
25
 
24
26
  load "#{recipes_dir}/recipes/crontab.rb"
25
- load "#{recipes_dir}/recipes/foreman.rb"
27
+ load "#{recipes_dir}/recipes/runit.rb"
26
28
  load "#{recipes_dir}/recipes/deploy.rb"
27
29
  load "#{recipes_dir}/recipes/login.rb"
28
30
  load "#{recipes_dir}/recipes/migrate.rb"
@@ -10,23 +10,23 @@ namespace :deploy do
10
10
  end
11
11
 
12
12
  task :start, :on_no_matching_servers => :continue, :except => { :no_release => true } do
13
- CapistranoEvroneRecipes::Util.with_roles(self, :app) { unicorn.start }
14
- CapistranoEvroneRecipes::Util.with_roles(self, :worker) { foreman.start }
13
+ CapistranoEvroneRecipes::Util.with_roles(self, :app) { unicorn.start }
14
+ CapistranoEvroneRecipes::Util.with_roles(self, :worker) { runit.start }
15
15
  end
16
16
 
17
17
  task :stop, :on_no_matching_servers => :continue, :except => { :no_release => true } do
18
- CapistranoEvroneRecipes::Util.with_roles(self, :app) { unicorn.stop }
19
- CapistranoEvroneRecipes::Util.with_roles(self, :worker) { foreman.stop }
18
+ CapistranoEvroneRecipes::Util.with_roles(self, :app) { unicorn.stop }
19
+ CapistranoEvroneRecipes::Util.with_roles(self, :worker) { runit.stop }
20
20
  end
21
21
 
22
22
  task :graceful_stop, :on_no_matching_servers => :continue, :except => { :no_release => true } do
23
- CapistranoEvroneRecipes::Util.with_roles(self, :app) { unicorn.graceful_stop }
24
- CapistranoEvroneRecipes::Util.with_roles(self, :worker) { foreman.stop }
23
+ CapistranoEvroneRecipes::Util.with_roles(self, :app) { unicorn.graceful_stop }
24
+ CapistranoEvroneRecipes::Util.with_roles(self, :worker) { runit.stop }
25
25
  end
26
26
 
27
27
  task :restart, :on_no_matching_servers => :continue, :except => {:no_release => true} do
28
- CapistranoEvroneRecipes::Util.with_roles(self, :app) { unicorn.restart }
29
- CapistranoEvroneRecipes::Util.with_roles(self, :worker) { foreman.restart }
28
+ CapistranoEvroneRecipes::Util.with_roles(self, :app) { unicorn.restart }
29
+ CapistranoEvroneRecipes::Util.with_roles(self, :worker) { runit.restart }
30
30
  end
31
31
  end
32
32
 
@@ -0,0 +1,59 @@
1
+ _cset(:runit_export_path) { "#{latest_release}/var/services" }
2
+ _cset(:runit_services_path) { "#{deploy_to}/services" }
3
+ _cset(:runit_export_cmd) { "#{fetch :bundle_cmd} exec foreman export runitu" }
4
+ _cset(:runit_procfile) { "#{latest_release}/Procfile" }
5
+ _cset(:foreman_concurency) { nil }
6
+
7
+ namespace :runit do
8
+
9
+ desc "Restart Procfile services"
10
+ task :restart, :roles => :worker, :on_no_matching_servers => :continue, :except => { :no_release => true } do
11
+ current_link = capture("readlink #{runit_services_path}/current").to_s.strip
12
+ if current_link == runit_export_path
13
+ stop
14
+ start
15
+ else
16
+ relink
17
+ end
18
+ end
19
+
20
+ task :relink, :roles => :worker, :on_no_matching_servers => :continue, :except => { :no_release => true } do
21
+ cmd = <<-EOF
22
+ (test -L previous && readlink previous | xargs rm -rf) ;
23
+ rm -f current.new &&
24
+ ln -s #{runit_export_path} current.new &&
25
+ rm -f previous &&
26
+ (test -L current && mv current previous) || true
27
+ && mv current.new current
28
+ EOF
29
+ cmd = cmd.gsub(/\n/, " ").gsub(/ +/, " ")
30
+ run("cd #{runit_services_path} && #{cmd}")
31
+ end
32
+
33
+ desc "Stop services"
34
+ task :stop, :roles => :worker, :on_no_matching_servers => :continue, :except => { :no_release => true } do
35
+ cmd = "for i in `ls -1 #{runit_services_path}/current`; do"
36
+ cmd << " sv -w 10 force-stop #{runit_services_path}/current/${i} ; done"
37
+ run(cmd)
38
+ end
39
+
40
+ desc "Start services"
41
+ task :start, :roles => :worker, :on_no_matching_servers => :continue, :except => { :no_release => true } do
42
+ cmd = "for i in `ls -1 #{runit_services_path}/current`; do"
43
+ cmd << " sv -v -w 10 up #{runit_services_path}/current/${i} ; done"
44
+ run(cmd)
45
+ end
46
+
47
+ desc "Export Procfile"
48
+ task :export, :roles => :worker, :on_no_matching_servers => :continue, :except => { :no_release => true } do
49
+ env = <<-EOF
50
+ RAILS_ENV=#{rails_env}
51
+ EOF
52
+ put(env, "#{release_path}/.env")
53
+
54
+ conc = fetch(:foreman_concurency) ? "-c #{fetch :foreman_concurency}" : ""
55
+ run "cd #{release_path} && #{runit_export_cmd} #{runit_export_path} -e #{release_path}/.env -l #{shared_path}/log -f #{runit_procfile} --root=#{release_path} -a #{application} #{conc} > /dev/null"
56
+ end
57
+ end
58
+
59
+ after "deploy:finalize_update", "runit:export"
@@ -3,7 +3,7 @@ module CapistranoEvroneRecipes
3
3
 
4
4
  MAJOR = 0
5
5
  MINOR = 1
6
- PATCH = 5
6
+ PATCH = 6
7
7
 
8
8
  def self.to_s
9
9
  "#{MAJOR}.#{MINOR}.#{PATCH}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano_evrone_recipes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -107,10 +107,10 @@ files:
107
107
  - lib/capistrano_evrone_recipes/recipes/assets.rb
108
108
  - lib/capistrano_evrone_recipes/recipes/crontab.rb
109
109
  - lib/capistrano_evrone_recipes/recipes/deploy.rb
110
- - lib/capistrano_evrone_recipes/recipes/foreman.rb
111
110
  - lib/capistrano_evrone_recipes/recipes/login.rb
112
111
  - lib/capistrano_evrone_recipes/recipes/migrate.rb
113
112
  - lib/capistrano_evrone_recipes/recipes/rails.rb
113
+ - lib/capistrano_evrone_recipes/recipes/runit.rb
114
114
  - lib/capistrano_evrone_recipes/recipes/silent.rb
115
115
  - lib/capistrano_evrone_recipes/recipes/sphinx.rb
116
116
  - lib/capistrano_evrone_recipes/recipes/unicorn.rb
@@ -1,48 +0,0 @@
1
- _cset(:foreman_services_path) { "#{deploy_to}/services/#{release_name}" }
2
- _cset(:foreman_cmd) { "#{fetch :bundle_cmd} exec foreman export runitu" }
3
- _cset(:foreman_procfile) { "#{release_path}/Procfile" }
4
- _cset(:foreman_concurency) { nil }
5
-
6
- namespace :foreman do
7
-
8
- desc "Restart Procfile services"
9
- task :restart, :roles => :worker, :on_no_matching_servers => :continue, :except => { :no_release => true } do
10
- cmd = <<-EOF
11
- (test -L previous && readlink previous | xargs rm -rf) ;
12
- rm -f current.new &&
13
- ln -s #{fetch :foreman_services_path} current.new &&
14
- rm -f previous &&
15
- (test -L current && mv current previous) || true
16
- && mv current.new current
17
- EOF
18
- cmd = cmd.gsub(/\n/, " ").gsub(/ +/, " ")
19
- run("cd #{deploy_to}/services && #{cmd}")
20
- end
21
-
22
- desc "Stop services"
23
- task :stop, :roles => :worker, :on_no_matching_servers => :continue, :except => { :no_release => true } do
24
- cmd = "for i in `ls -1 #{deploy_to}/services/current`; do"
25
- cmd << " sv -w 10 down #{deploy_to}/services/current/${i} ; done"
26
- run(cmd)
27
- end
28
-
29
- desc "Start services"
30
- task :start, :roles => :worker, :on_no_matching_servers => :continue, :except => { :no_release => true } do
31
- cmd = "for i in `ls -1 #{deploy_to}/services/current`; do"
32
- cmd << " sv -v -w 10 up #{deploy_to}/services/current/${i} ; done"
33
- run(cmd)
34
- end
35
-
36
- desc "Export Procfile"
37
- task :export, :roles => :worker, :on_no_matching_servers => :continue, :except => { :no_release => true } do
38
- env = <<-EOF
39
- RAILS_ENV=#{rails_env}
40
- EOF
41
- put(env, "#{release_path}/.env")
42
-
43
- conc = fetch(:foreman_concurency) ? "-c #{fetch :foreman_concurency}" : ""
44
- run "cd #{release_path} && #{fetch :foreman_cmd} #{fetch :foreman_services_path} -e #{release_path}/.env -l #{shared_path}/log -f #{fetch :foreman_procfile} --root=#{release_path} -a #{application} #{conc} > /dev/null"
45
- end
46
- end
47
-
48
- after "deploy:finalize_update", "foreman:export"