capistrano-foreman 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5938a6e7555b79410d32279c0634bb3319e3d668
4
- data.tar.gz: e0b9fb4b1b2f787f6d093f0408643ad723fcc00e
3
+ metadata.gz: a074314158aaf705130e0fc22a91fe9cd598e70b
4
+ data.tar.gz: 30cf5f1dc0b200c517247310b4de12a05e800ffe
5
5
  SHA512:
6
- metadata.gz: c0f04d9f7fa93dde0c3950fb6ba97b99ae4c825f144fff7e24031555e9391a662bbf46b9513b961eab36172b7ce18f3649f9a728dacef2ff3d14b8063c20275b
7
- data.tar.gz: b8bcc2cf08aec5edebfd61304f97006d273e43f43ba3b4819ec199644a193aa20b618dc487d0633e65fbf648dd7e1328bb02d30e13566cc0623caf0cfad428bc
6
+ metadata.gz: 4f093dd032f43b9114beeee3939d6fce1dbef4cd33bd9e41ba9be5e8a506d972693ff45766257d96fdca7c7147af76fde745178127e88c787c036ea3c9dc5f2f
7
+ data.tar.gz: 9f4997e77dd54fc68614c980b9b58ea182f4d3cbfb9e75ed40a9a62b31954d2557a256c3a19e6df0471fad2c3e8a83079129d38f3bbb9270e97a9d2b592cc44b
data/README.md CHANGED
@@ -14,7 +14,7 @@ Add this to your `Capfile`:
14
14
  require 'capistrano/foreman'
15
15
 
16
16
  # Default settings
17
- set :foreman_use_sudo, false
17
+ set :foreman_use_sudo, false # Set to :rbenv for rbenv sudo, :rvm for rvmsudo or true for normal sudo
18
18
  set :foreman_roles, :all
19
19
  set :foreman_template, 'upstart'
20
20
  set :foreman_export_path, File.join(Dir.home, '.init')
@@ -14,7 +14,7 @@ Gem::Specification.new do |gem|
14
14
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
15
  gem.name = "capistrano-foreman"
16
16
  gem.require_paths = ["lib"]
17
- gem.version = '1.1.0'
17
+ gem.version = '1.2.0'
18
18
 
19
19
  gem.add_dependency 'capistrano', '~> 3.1'
20
20
  gem.add_dependency 'capistrano-bundler', '~> 1.1'
@@ -7,16 +7,18 @@ namespace :foreman do
7
7
  desc 'Export the Procfile'
8
8
  task :export do
9
9
  on roles fetch(:foreman_roles) do
10
- within release_path do
11
- opts = {
12
- app: fetch(:application),
13
- log: File.join(shared_path, 'log'),
14
- }.merge fetch(:foreman_options, {})
10
+ opts = {
11
+ app: fetch(:application),
12
+ log: File.join(shared_path, 'log'),
13
+ }.merge fetch(:foreman_options, {})
14
+
15
+ execute(:mkdir, "-p", opts[:log])
15
16
 
16
- execute :foreman, 'export',
17
+ within release_path do
18
+ foreman_exec :foreman, 'export',
17
19
  fetch(:foreman_template),
18
20
  fetch(:foreman_export_path),
19
- opts.map { |opt, value| "--#{opt}='#{value}'" }.join(' ')
21
+ opts.map { |opt, value| "--#{opt}=\"#{value}\"" }.join(' ')
20
22
  end
21
23
  end
22
24
  end
@@ -24,31 +26,51 @@ namespace :foreman do
24
26
  desc 'Start the application services'
25
27
  task :start do
26
28
  on roles fetch(:foreman_roles) do
27
- sudo :start, fetch(:foreman_app)
29
+ foreman_exec :start, fetch(:foreman_app)
28
30
  end
29
31
  end
30
32
 
31
33
  desc 'Stop the application services'
32
34
  task :stop do
33
35
  on roles fetch(:foreman_roles) do
34
- sudo :stop, fetch(:foreman_app)
36
+ foreman_exec :stop, fetch(:foreman_app)
35
37
  end
36
38
  end
37
39
 
38
40
  desc 'Restart the application services'
39
41
  task :restart do
40
42
  on roles fetch(:foreman_roles) do
41
- sudo :restart, fetch(:foreman_app)
43
+ foreman_exec :restart, fetch(:foreman_app)
44
+ end
45
+ end
46
+
47
+ def foreman_exec(*args)
48
+ sudo_type = fetch(:foreman_use_sudo)
49
+ case sudo_type.to_s
50
+ when 'rbenv'
51
+ # this is required because 'rbenv sudo'
52
+ # is not recognized by bundle_bins
53
+ args.unshift(:bundle, :exec) if args[0].to_s == "foreman"
54
+ execute(:rbenv, :sudo, *args)
55
+ when 'rvm'
56
+ execute(:rvmsudo, *args)
57
+ else
58
+ sudo_type ? sudo(*args) : execute(*args)
42
59
  end
43
60
  end
44
61
  end
45
62
 
46
63
  namespace :load do
47
64
  task :defaults do
48
- set :bundle_bins, fetch(:bundle_bins, []).push(%w(foreman))
65
+ set :bundle_bins, fetch(:bundle_bins, []).push(:foreman)
66
+ set :foreman_use_sudo, false
49
67
  set :foreman_template, 'upstart'
50
68
  set :foreman_export_path, '/etc/init/sites'
51
69
  set :foreman_roles, :all
52
70
  set :foreman_app, -> { fetch(:application) }
71
+
72
+ if !fetch(:rvm_map_bins).nil?
73
+ set :rvm_map_bins, fetch(:rvm_map_bins).push('foreman')
74
+ end
53
75
  end
54
76
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-foreman
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johannes Gorset
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-11-01 00:00:00.000000000 Z
12
+ date: 2015-04-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capistrano