tvd-runit 0.0.1 → 0.0.2
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.
- data/VERSION +1 -1
- data/cookbooks/runit/attributes/default.rb +6 -1
- data/cookbooks/runit/definitions/runit_service.rb +94 -0
- data/cookbooks/runit/files/default/sv-log-run +6 -0
- data/cookbooks/runit/templates/default/envdir.erb +1 -0
- data/cookbooks/runit/templates/default/sv-log-config.erb +4 -0
- metadata +6 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
@@ -1 +1,6 @@
|
|
1
|
-
default[:
|
1
|
+
default[:runit][:services_run] = "/etc/service"
|
2
|
+
default[:runit][:num_old_logs] = 5
|
3
|
+
default[:runit][:max_log_size] = 500000000
|
4
|
+
default[:runit][:max_log_time] = 86400
|
5
|
+
default[:runit][:start_timeout] = 60
|
6
|
+
default[:runit][:stop_timeout] = 60
|
@@ -0,0 +1,94 @@
|
|
1
|
+
#
|
2
|
+
# Cookbook Name:: runit
|
3
|
+
# Definition:: runit_service
|
4
|
+
#
|
5
|
+
# Copyright 2008-2009, Opscode, Inc.
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
|
20
|
+
define :runit_service, :services_defined => nil, :only_if => false, :options => Hash.new do
|
21
|
+
params[:template_name] ||= params[:name]
|
22
|
+
params[:restart] ||= "restart"
|
23
|
+
params[:env] ||= {}
|
24
|
+
|
25
|
+
svdir = "#{params[:services_defined]}/#{params[:name]}"
|
26
|
+
|
27
|
+
directory svdir
|
28
|
+
|
29
|
+
cookbook_file "#{svdir}/run" do
|
30
|
+
mode 0755
|
31
|
+
source "sv-#{params[:template_name]}-run"
|
32
|
+
cookbook params[:cookbook] if params[:cookbook]
|
33
|
+
end
|
34
|
+
|
35
|
+
directory "#{svdir}/log"
|
36
|
+
|
37
|
+
cookbook_file "#{svdir}/log/run" do
|
38
|
+
mode 0755
|
39
|
+
source "sv-log-run"
|
40
|
+
cookbook "runit"
|
41
|
+
end
|
42
|
+
|
43
|
+
template "#{svdir}/log/config" do
|
44
|
+
mode 0644
|
45
|
+
source "sv-log-config.erb"
|
46
|
+
cookbook "runit"
|
47
|
+
if params[:options].respond_to?(:has_key?)
|
48
|
+
variables :options => params[:options]
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
directory "#{svdir}/env"
|
53
|
+
|
54
|
+
runit_env = {
|
55
|
+
"PATH" => ENV['PATH'],
|
56
|
+
"HOME" => node[:home_dir]
|
57
|
+
}
|
58
|
+
|
59
|
+
runit_env.merge(params[:env]).each do |varname, value|
|
60
|
+
template "#{svdir}/env/#{varname}" do
|
61
|
+
source "envdir.erb"
|
62
|
+
mode 0644
|
63
|
+
cookbook "runit"
|
64
|
+
variables :value => value
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
ruby_block "supervise_#{params[:name]}_sleep" do
|
69
|
+
block do
|
70
|
+
(1..6).each {|i| sleep 1 unless ::FileTest.pipe?("#{svdir}/supervise/ok") }
|
71
|
+
end
|
72
|
+
not_if { FileTest.pipe?("#{svdir}/supervise/ok") || $testrun }
|
73
|
+
end
|
74
|
+
|
75
|
+
ruby_block "supervise_#{params[:name]}_log_sleep" do
|
76
|
+
block do
|
77
|
+
(1..6).each {|i| sleep 1 unless ::FileTest.pipe?("#{svdir}/log/supervise/ok") }
|
78
|
+
end
|
79
|
+
not_if { FileTest.pipe?("#{svdir}/supervise/log/ok") || $testrun }
|
80
|
+
end
|
81
|
+
|
82
|
+
execute "#{params[:restart]}_#{params[:name]}_service" do
|
83
|
+
command "sv #{params[:restart]} #{params[:name]}"
|
84
|
+
subscribes :run, resources(:cookbook_file => "#{svdir}/run"), :delayed
|
85
|
+
action :nothing
|
86
|
+
end
|
87
|
+
|
88
|
+
execute "hup_#{params[:name]}_log" do
|
89
|
+
command "sv hup #{params[:name]}/log"
|
90
|
+
subscribes :run, resources(:cookbook_file => "#{svdir}/log/run")
|
91
|
+
subscribes :run, resources(:template => "#{svdir}/log/config")
|
92
|
+
action :nothing
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= @value %>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tvd-runit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-09-
|
12
|
+
date: 2012-09-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: microwave
|
@@ -34,6 +34,10 @@ extensions: []
|
|
34
34
|
extra_rdoc_files: []
|
35
35
|
files:
|
36
36
|
- cookbooks/runit/attributes/default.rb
|
37
|
+
- cookbooks/runit/definitions/runit_service.rb
|
38
|
+
- cookbooks/runit/files/default/sv-log-run
|
39
|
+
- cookbooks/runit/templates/default/envdir.erb
|
40
|
+
- cookbooks/runit/templates/default/sv-log-config.erb
|
37
41
|
- lib/development.rb
|
38
42
|
- lib/tvd-runit.rb
|
39
43
|
- lib/tvd-runit/version.rb
|