capistrano-background 0.1.2 → 0.1.3
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +4 -2
- data/capistrano-background.gemspec +2 -1
- data/lib/capistrano/background.rb +2 -1
- data/lib/capistrano/background/command.rb +20 -0
- data/lib/capistrano/background/version.rb +1 -1
- data/lib/capistrano/tasks/background.rake +8 -27
- metadata +19 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7cf30a97b71b01cd667c9e7532d3df8bd7aa059
|
4
|
+
data.tar.gz: 2aeaeae84fd996c505c0b30365a558f3d037a2f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1be3ae22efe69e4fc54b990f82eb00642e1fefd93ffbe91a2676c2a9a17d720cd904fd3947818a6b6cb630dfdd9d70fe10297d872933606449ee2a04776bc94
|
7
|
+
data.tar.gz: f7aa6be5d1509f1ee1aa89ad826bc37e6e76eb71695fcf51e7a51709c40279cc93a1fcf570d12a403dac6bab864bce0f21162960613ae8dcb72f4d29b88d21ac
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -7,7 +7,8 @@ Run background process for capistrano.
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
9
|
```ruby
|
10
|
-
gem 'capistrano-background'
|
10
|
+
gem 'capistrano-background', group: :development
|
11
|
+
gem 'terminate'
|
11
12
|
```
|
12
13
|
|
13
14
|
And then execute:
|
@@ -27,7 +28,8 @@ Add your background processes.
|
|
27
28
|
```Ruby
|
28
29
|
add_background_process({
|
29
30
|
:id => :scheduler,
|
30
|
-
:execute => [:rake, 'scheduler']
|
31
|
+
:execute => [:rake, 'scheduler'],
|
32
|
+
:timeout => 60 # kill process after waiting this time (seconds)
|
31
33
|
})
|
32
34
|
```
|
33
35
|
It will run `rake scheduler` in background when deploy. You can also use command:
|
@@ -17,7 +17,8 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
|
-
spec.add_dependency "capistrano"
|
20
|
+
spec.add_dependency "capistrano", ">= 3.0.0"
|
21
|
+
spec.add_dependency "terminate", ">= 0.1.1"
|
21
22
|
|
22
23
|
spec.add_development_dependency "bundler", "~> 1.10"
|
23
24
|
spec.add_development_dependency "rake", "~> 10.0"
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module SSHKit
|
2
|
+
class Command
|
3
|
+
alias_method :orig_in_background, :in_background
|
4
|
+
|
5
|
+
def in_background(&_block)
|
6
|
+
return yield unless options[:run_in_background]
|
7
|
+
pid_file = options[:pid_file]
|
8
|
+
if pid_file.nil?
|
9
|
+
orig_in_background(&_block)
|
10
|
+
else
|
11
|
+
env_str = environment_string
|
12
|
+
if env_str.nil?
|
13
|
+
sprintf("( nohup %s > /dev/null & \\echo $! > #{pid_file})", yield)
|
14
|
+
else
|
15
|
+
sprintf(" && ( #{env_str} nohup %s > /dev/null & \\echo $! > #{pid_file})", yield)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -1,24 +1,3 @@
|
|
1
|
-
module SSHKit
|
2
|
-
class Command
|
3
|
-
alias_method :orig_in_background, :in_background
|
4
|
-
|
5
|
-
def in_background(&_block)
|
6
|
-
return yield unless options[:run_in_background]
|
7
|
-
pid_file = options[:pid_file]
|
8
|
-
if pid_file.nil?
|
9
|
-
orig_in_background(&_block)
|
10
|
-
else
|
11
|
-
env_str = environment_string
|
12
|
-
if env_str.nil?
|
13
|
-
sprintf("( nohup %s > /dev/null & \\echo $! > #{pid_file})", yield)
|
14
|
-
else
|
15
|
-
sprintf(" && ( #{env_str} nohup %s > /dev/null & \\echo $! > #{pid_file})", yield)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
1
|
namespace :load do
|
23
2
|
task :defaults do
|
24
3
|
set :background_default_hooks, true
|
@@ -43,16 +22,16 @@ namespace :background do
|
|
43
22
|
end
|
44
23
|
|
45
24
|
def pid_process_exists?(pid_file)
|
46
|
-
file_exists?(pid_file)
|
25
|
+
file_exists?(pid_file) && test(*%{kill -0 `cat #{pid_file}`})
|
47
26
|
end
|
48
27
|
|
49
28
|
def file_exists?(file)
|
50
|
-
test(
|
29
|
+
test(*%{[ -f #{file} ]})
|
51
30
|
end
|
52
31
|
|
53
32
|
def quiet_process(pid_file)
|
54
33
|
if file_exists? pid_file
|
55
|
-
background "kill -
|
34
|
+
background "kill -TERM `cat #{pid_file}`"
|
56
35
|
end
|
57
36
|
end
|
58
37
|
|
@@ -65,9 +44,11 @@ namespace :background do
|
|
65
44
|
end
|
66
45
|
end
|
67
46
|
|
68
|
-
def stop_process(pid_file)
|
47
|
+
def stop_process(pid_file, timeout)
|
69
48
|
if file_exists? pid_file
|
70
|
-
|
49
|
+
if pid_process_exists? pid_file
|
50
|
+
rake "terminate `cat #{pid_file}` -- -t #{timeout}"
|
51
|
+
end
|
71
52
|
execute "rm #{pid_file}"
|
72
53
|
end
|
73
54
|
end
|
@@ -99,7 +80,7 @@ namespace :background do
|
|
99
80
|
role = options[:role] || :app
|
100
81
|
on roles role do
|
101
82
|
within release_path do
|
102
|
-
stop_process(get_pid_file(options))
|
83
|
+
stop_process(get_pid_file(options), options[:timeout] || 60)
|
103
84
|
end
|
104
85
|
end
|
105
86
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-background
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chen Yi-Cyuan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
@@ -16,14 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 3.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 3.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: terminate
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.1.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.1.1
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,6 +100,7 @@ files:
|
|
86
100
|
- capistrano-background.gemspec
|
87
101
|
- lib/capistrano-background.rb
|
88
102
|
- lib/capistrano/background.rb
|
103
|
+
- lib/capistrano/background/command.rb
|
89
104
|
- lib/capistrano/background/version.rb
|
90
105
|
- lib/capistrano/tasks/background.rake
|
91
106
|
homepage: https://github.com/emn178/capistrano-background.git
|