capistrano-background 0.1.0 → 0.1.1

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: 92d9c499944e773fd9b37ec7102c37c2a3f8bfbe
4
- data.tar.gz: 6d32e91a44c96a1b90d19b09eebcbaacd3be8387
3
+ metadata.gz: ba4126661a4a88a0a004ee7c3584f6772252fbe1
4
+ data.tar.gz: 3d966c6bba0adca375b47201c6db477d7b3d8032
5
5
  SHA512:
6
- metadata.gz: 6889436465b54c390d6a7f366ae43089999367e34234d1c44f70d2b4a4c8758218faccd5808e29649c03155804ce1ce712267ad310adf657a8857f4000b5afc2
7
- data.tar.gz: 267fde493740a83512412d6fdf893355887f04e5b2271de398702670e99ad95e12e2fe0f1185acd456870537868c97086c906a8033557e9bf61a86f38b2b51e6
6
+ metadata.gz: 854d9b14f56bbf287ba91a49ae6daddda56dfa10cdd4c1c5b6312a55b1c5989b923c129a1d0a521c4a21e881ebb4cde4193e03766f2cc84df68c493a864001e9
7
+ data.tar.gz: 164af789c60a8c466966291edf66f791d3279ae8a39b2cb08133e9112f4e78fb02d9adba1dfa93f36e99ac427d019a1f397f56ebef145770892f0f78f4429084
@@ -0,0 +1,3 @@
1
+ # v0.1.1 / 2015-11-01
2
+
3
+ Create project
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module Background
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
@@ -8,7 +8,12 @@ module SSHKit
8
8
  if pid_file.nil?
9
9
  orig_in_background(&_block)
10
10
  else
11
- sprintf("( nohup %s > /dev/null & \\echo $! > #{pid_file})", yield)
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
12
17
  end
13
18
  end
14
19
  end
@@ -16,10 +21,20 @@ end
16
21
 
17
22
  namespace :load do
18
23
  task :defaults do
24
+ set :background_default_hooks, true
19
25
  set :background_processes, []
20
26
  end
21
27
  end
22
28
 
29
+ namespace :deploy do
30
+ before :starting, :check_background_hooks do
31
+ invoke 'background:add_default_hooks' if fetch(:background_default_hooks)
32
+ end
33
+ after :publishing, :restart_background do
34
+ invoke 'background:restart' if fetch(:background_default_hooks)
35
+ end
36
+ end
37
+
23
38
  namespace :background do
24
39
  processes = []
25
40
 
@@ -35,11 +50,17 @@ namespace :background do
35
50
  test(*("[ -f #{file} ]").split(' '))
36
51
  end
37
52
 
53
+ def quiet_process(pid_file)
54
+ if file_exists? pid_file
55
+ background "kill -USR1 `cat #{pid_file}`"
56
+ end
57
+ end
58
+
38
59
  def start_process(pid_file, options)
39
60
  stage = fetch :stage
40
61
  args = options[:execute]
41
62
  args << {:pid_file => pid_file}
42
- with(:RAILS_ENV => "#{stage} && ") do
63
+ with(:RAILS_ENV => stage) do
43
64
  background *args
44
65
  end
45
66
  end
@@ -58,6 +79,19 @@ namespace :background do
58
79
  after 'deploy:published', 'background:start'
59
80
  end
60
81
 
82
+ desc 'Quiet background processes'
83
+ task :quiet do
84
+ background_processes = fetch :background_processes
85
+ background_processes.each do |options|
86
+ role = options[:role] || :app
87
+ on roles role do
88
+ within release_path do
89
+ quiet_process(get_pid_file(options))
90
+ end
91
+ end
92
+ end
93
+ end
94
+
61
95
  desc 'Stop background processes'
62
96
  task :stop do
63
97
  background_processes = fetch :background_processes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-background
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chen Yi-Cyuan
@@ -76,6 +76,7 @@ files:
76
76
  - ".gitignore"
77
77
  - ".rspec"
78
78
  - ".travis.yml"
79
+ - CHANGELOG.md
79
80
  - Gemfile
80
81
  - LICENSE.txt
81
82
  - README.md