daemontools 0.2.0 → 0.2.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.
- checksums.yaml +4 -4
- data/bin/daemontools-gen +13 -4
- data/lib/daemontools.rb +30 -2
- data/lib/daemontools/capistrano.rb +2 -1
- data/lib/daemontools/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5703423d017dfd15356942bfb9c15b1bf90a0066e0ee3cb44d6465c0028a926
|
4
|
+
data.tar.gz: f7cb58a362f20b50c777a935b9468d7ca290b6d1f9c655321dc37d0b3103b069
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 990027123b11e7049fe904a19ac9fe30ae0fdbd6823a61d3640d0e9506f95daec95d6d7fa09878ef18d8fcf89a1d5682aec99591eb35e6134a16a4901cdfd27c
|
7
|
+
data.tar.gz: 5d668f9a9bcd887332110e549e738a29bbfcce6e696cf45c57fa27545d5d54a3d2f91116562cefdeb81dc26d349b423ae1fd69e4688a4a23caf1510d2a9343b0
|
data/bin/daemontools-gen
CHANGED
@@ -10,13 +10,22 @@ puts "Building svc services for roles #{roles} .."
|
|
10
10
|
old_path = ARGV[2] || ''
|
11
11
|
new_path = ARGV[3] || ''
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
def need_remove_old_services?(old_path, new_path)
|
14
|
+
# If no new path there is no reason to try remove old services
|
15
|
+
return false if new_path.nil? || new_path.empty?
|
16
|
+
# If no old path there is no reason to try remove old services
|
17
|
+
return false if old_path.nil? || old_path.empty?
|
18
|
+
# Check if config files are exists
|
19
|
+
File.exist?("#{old_path}/config/services.rb") && File.exist?("#{new_path}/config/services.rb")
|
20
|
+
end
|
21
|
+
|
22
|
+
if need_remove_old_services?(old_path, new_path)
|
17
23
|
previous_builder = Daemontools::Builder.new("#{old_path}/config/services.rb")
|
18
24
|
current_builder = Daemontools::Builder.new("#{new_path}/config/services.rb")
|
19
25
|
remover = Daemontools::Remover.new(roles, previous_builder, current_builder)
|
20
26
|
remover.remove_unused_services
|
21
27
|
current_builder.gen(roles, environment)
|
28
|
+
else
|
29
|
+
builder = Daemontools::Builder.new("#{Dir.pwd}/config/services.rb")
|
30
|
+
builder.gen(roles, environment)
|
22
31
|
end
|
data/lib/daemontools.rb
CHANGED
@@ -6,15 +6,20 @@ require 'erb'
|
|
6
6
|
|
7
7
|
module Daemontools
|
8
8
|
class << self
|
9
|
-
attr_accessor :svc_root, :log_root
|
9
|
+
attr_accessor :svc_root, :log_root, :tmp_root
|
10
10
|
end
|
11
11
|
@svc_root = '/etc/service'
|
12
12
|
@log_root = '/var/log/svc'
|
13
|
+
@tmp_root = '/tmp'
|
13
14
|
|
14
15
|
def self.exists?(name)
|
15
16
|
check_service_exists(name, false)
|
16
17
|
end
|
17
18
|
|
19
|
+
def self.tmp_exists?(name)
|
20
|
+
Dir.exists?("#{@tmp_root}/daemontools_service_#{name}")
|
21
|
+
end
|
22
|
+
|
18
23
|
def self.status(name)
|
19
24
|
check_service_exists(name)
|
20
25
|
r = `sudo svstat #{@path} 2>&1`
|
@@ -57,6 +62,29 @@ module Daemontools
|
|
57
62
|
true
|
58
63
|
end
|
59
64
|
|
65
|
+
def self.add_empty_tmp(name)
|
66
|
+
path = "#{@tmp_root}/daemontools_service_#{name}"
|
67
|
+
Dir.mkdir(path) unless Dir.exists?(path)
|
68
|
+
true
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.move_tmp(name)
|
72
|
+
tmp_path = "#{@tmp_root}/daemontools_service_#{name}"
|
73
|
+
svc_path = "#{@svc_root}/#{name}"
|
74
|
+
|
75
|
+
r = `mv #{tmp_path} #{svc_path}`
|
76
|
+
raise r if $?.exitstatus != 0
|
77
|
+
raise r if ! r.empty?
|
78
|
+
|
79
|
+
now = Time.now.to_f
|
80
|
+
while `sudo svstat #{svc_path} 2>&1`.match(/unable to open/i)
|
81
|
+
raise "Timeout wait for svc add service" if Time.now.to_f - now > 10
|
82
|
+
sleep 0.1
|
83
|
+
end
|
84
|
+
|
85
|
+
true
|
86
|
+
end
|
87
|
+
|
60
88
|
def self.add(name, command, options = {})
|
61
89
|
@name = name
|
62
90
|
@command = command
|
@@ -91,7 +119,7 @@ module Daemontools
|
|
91
119
|
end
|
92
120
|
|
93
121
|
def self.delete(name, rm_cmd = nil)
|
94
|
-
|
122
|
+
return false unless exists?(name)
|
95
123
|
stop(name)
|
96
124
|
cmd = rm_cmd.nil? ? "sudo rm -rf #{@path} 2>&1" : "#{rm_cmd} #{@path}"
|
97
125
|
r = `#{cmd}`
|
@@ -16,10 +16,11 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
16
16
|
path = fetch(:previous_release)
|
17
17
|
puts "rollback 1"
|
18
18
|
else
|
19
|
+
previous_release_path = fetch(:previous_release)
|
19
20
|
path = fetch(:release_path)
|
20
21
|
|
21
22
|
servers.each do |server, roles|
|
22
|
-
command = "cd #{path} && bundle exec daemontools-gen #{fetch :rails_env, "production"} #{roles.join(',')} #{
|
23
|
+
command = "cd #{path} && bundle exec daemontools-gen #{fetch :rails_env, "production"} #{roles.join(',')} #{previous_release_path} #{current_path}"
|
23
24
|
run command, :hosts => server
|
24
25
|
end
|
25
26
|
end
|
data/lib/daemontools/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: daemontools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -102,8 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
requirements: []
|
105
|
-
|
106
|
-
rubygems_version: 2.7.9
|
105
|
+
rubygems_version: 3.0.8
|
107
106
|
signing_key:
|
108
107
|
specification_version: 4
|
109
108
|
summary: Distributed storage
|