Commit d935d3c75737bd07d69f6502d5ca1afc0fccd9f1
Exists in
master
and in
17 other branches
Merge branch 'runit' into 'master'
Runit
Showing
13 changed files
with
620 additions
and
0 deletions
Show diff stats
config/projects/gitlab.rb
@@ -33,6 +33,7 @@ dependency "gitlab-webui" | @@ -33,6 +33,7 @@ dependency "gitlab-webui" | ||
33 | dependency "chef-gem" | 33 | dependency "chef-gem" |
34 | dependency "gitlab-ctl" | 34 | dependency "gitlab-ctl" |
35 | dependency "gitlab-cookbooks" | 35 | dependency "gitlab-cookbooks" |
36 | +dependency "runit" | ||
36 | 37 | ||
37 | # version manifest file | 38 | # version manifest file |
38 | dependency "version-manifest" | 39 | dependency "version-manifest" |
files/gitlab-cookbooks/dna.json
@@ -0,0 +1,11 @@ | @@ -0,0 +1,11 @@ | ||
1 | +maintainer "GitLab.com" | ||
2 | +maintainer_email "support@gitlab.com" | ||
3 | +license "MIT" | ||
4 | +description "Install and configure GitLab from Omnibus" | ||
5 | +long_description "Install and configure GitLab from Omnibus" | ||
6 | +version "0.0.1" | ||
7 | +recipe "gitlab", "Configures GitLab from Omnibus" | ||
8 | + | ||
9 | +supports "ubuntu" | ||
10 | + | ||
11 | +depends "runit" |
@@ -0,0 +1 @@ | @@ -0,0 +1 @@ | ||
1 | +include_recipe "runit" |
@@ -0,0 +1,228 @@ | @@ -0,0 +1,228 @@ | ||
1 | +Description | ||
2 | +=========== | ||
3 | + | ||
4 | +Installs runit and provides `runit_service` definition for managing new | ||
5 | +services under runit. | ||
6 | + | ||
7 | +This cookbook does not use runit to replace system init, nor are there | ||
8 | +plans to do so. | ||
9 | + | ||
10 | +For more information about runit: | ||
11 | + | ||
12 | +* http://smarden.org/runit/ | ||
13 | + | ||
14 | +Changes | ||
15 | +======= | ||
16 | + | ||
17 | +## v0.14.2 | ||
18 | + | ||
19 | +Roadmap | ||
20 | +------- | ||
21 | + | ||
22 | +* [CHEF-154] - implement lwrp for runit service | ||
23 | + | ||
24 | +Requirements | ||
25 | +============ | ||
26 | + | ||
27 | +## Platform: | ||
28 | + | ||
29 | +* Debian/Ubuntu | ||
30 | +* Gentoo | ||
31 | + | ||
32 | +Attributes | ||
33 | +========== | ||
34 | + | ||
35 | +See `attributes/default.rb` for defaults. | ||
36 | + | ||
37 | +* `node['runit']['sv_bin']` - Full path to the `sv` binary. | ||
38 | +* `node['runit']['chpst_bin']` - Full path to the `chpst` binary. | ||
39 | +* `node['runit']['service_dir']` - Full path to the default "services" | ||
40 | + directory where enabled services are linked. | ||
41 | +* `node['runit']['sv_dir']` - Full path to the directory where the | ||
42 | + service lives, which gets linked to `service_dir`. | ||
43 | + | ||
44 | +Recipes | ||
45 | +======= | ||
46 | + | ||
47 | +default | ||
48 | +------- | ||
49 | + | ||
50 | +Installs and sets up runit on the system. Assumes a package | ||
51 | +installation, so native package must exist. This recipe will make sure | ||
52 | +that the runsvdir process gets started, ensures that inittab is | ||
53 | +updated with the SV entry. The package will be preseeded on | ||
54 | +ubuntu/debian signal init, otherwise the appropriate action is chosen | ||
55 | +to notify the runsvdir command. | ||
56 | + | ||
57 | +Older versions of Ubuntu (<= 10.04) are supported, but support may be | ||
58 | +removed in a future version. | ||
59 | + | ||
60 | +Definitions | ||
61 | +=========== | ||
62 | + | ||
63 | +The definition in this cookbook will be deprecated by an LWRP in a | ||
64 | +future version. See __Roadmap__. | ||
65 | + | ||
66 | +runit\_service | ||
67 | +-------------- | ||
68 | + | ||
69 | +This definition includes `recipe[runit]` to ensure it is installed | ||
70 | +first. As LWRPs cannot use `include_recipe`, this will not be | ||
71 | +available in future versions, so runit will need to be in a role or | ||
72 | +node run list. | ||
73 | + | ||
74 | +Sets up a new service to be managed and supervised by runit. It will | ||
75 | +be created in the `node['runit']['sv_dir']` unless otherwise specified | ||
76 | +in the `directory` parameter (see below). | ||
77 | + | ||
78 | +### Parameters: | ||
79 | + | ||
80 | +* `name` - Name of the service. This will be used in the template file | ||
81 | + names (see __Usage__), as well as the name of the service resource | ||
82 | + created in the definition. | ||
83 | +* `directory` - the directory where the service's configuration and | ||
84 | + scripts should be located. Default is `node['runit']['sv_dir']`. | ||
85 | +* `only_if` - unused, will be removed in a future version (won't be | ||
86 | + present in lwrp). Default is false. | ||
87 | +* `finish_script` - if true, a finish script should be created. | ||
88 | + Default is false. For more information see: [Description of runsv](http://smarden.org/runit/runsv.8.html). | ||
89 | +* `control` - Array of signals to create a control directory with | ||
90 | + control scripts (e.g., `sv-SERVICE-control-SIGNAL.erb`, where | ||
91 | + SERVICE is the name parameter for the service name, and SIGNAL is | ||
92 | + the Unix signal to send. Default is an empty array. For more | ||
93 | + information see: | ||
94 | + [Customize Control](http://smarden.org/runit/runsv.8.html) | ||
95 | +* `run_restart` - if true, the service resource will subscribe to | ||
96 | + changes to the run script and restart itself when it is modified. | ||
97 | + Default is true. | ||
98 | +* `active_directory` - used for user-specific services. Default is | ||
99 | + `node['runit']['service_dir']`. | ||
100 | +* `owner` - userid of the owner for the service's files, and should be | ||
101 | + used in the run template with chpst to ensure the service runs as | ||
102 | + that user. Default is root. | ||
103 | +* `group` - groupid of the group for the service's files, and should | ||
104 | + be used in the run template with chpst to ensure the service runs as | ||
105 | + that group. Default is root. | ||
106 | +* `template_name` - specify an alternate name for the templates | ||
107 | + instead of basing them on the name parameter. Default is the name parameter. | ||
108 | +* `start_command` - The command used to start the service in | ||
109 | + conjunction with the `sv` command and the `service_dir` name. | ||
110 | + Default is `start`. | ||
111 | +* `stop_command` - The command used to stop the service in conjunction | ||
112 | + with the `sv` command and the `service_dir` name. Default is `stop`. | ||
113 | +* `restart_command` - The command used to restart the service in | ||
114 | + conjunction with the `sv` command and the `service_dir` name. You | ||
115 | + may need to modify this to send an alternate signal to restart the | ||
116 | + service depending on the nature of the process. Default is `restart` | ||
117 | +* `status_command` - The command used to check status for the service in | ||
118 | + conjunction with the `sv` command and the `service_dir` name. This | ||
119 | + is used by chef when checking the current resource state in managing | ||
120 | + the service. Default is `status`. | ||
121 | +* `options` - a Hash of variables to pass into the run and log/run | ||
122 | + templates with the template resource `variables` parameter. | ||
123 | + Available inside the template(s) as `@options`. Default is an empty Hash. | ||
124 | +* `env` - | ||
125 | + | ||
126 | +### Examples: | ||
127 | + | ||
128 | +Create templates for `sv-myservice-run.erb` and | ||
129 | +`sv-myservice-log-run.erb` that have the commands for starting | ||
130 | +myservice and its logger. | ||
131 | + | ||
132 | + runit_service "myservice" | ||
133 | + | ||
134 | +See __Usage__ for expanded examples. | ||
135 | + | ||
136 | +Resources/Providers | ||
137 | +=================== | ||
138 | + | ||
139 | +None yet. See __Roadmap__. | ||
140 | + | ||
141 | +Usage | ||
142 | +===== | ||
143 | + | ||
144 | +To get runit installed on supported platforms, use `recipe[runit]`. | ||
145 | +Once it is installed, use the `runit_service` definition to set up | ||
146 | +services to be managed by runit. Do note that once | ||
147 | +[CHEF-154](http://tickets.opscode.com/browse/CHEF-154) is implemented, | ||
148 | +some of the usage/implementation here will change. In order to use the | ||
149 | +`runit_service` definition, two templates must be created for the | ||
150 | +service, `cookbook_name/templates/default/sv-SERVICE-run.erb` and | ||
151 | +`cookbook_name/templates/default/sv-SERVICE-log-run.erb`. Replace | ||
152 | +`SERVICE` with the name of the service you're managing. For more usage, | ||
153 | +see __Examples__. | ||
154 | + | ||
155 | +Examples | ||
156 | +-------- | ||
157 | + | ||
158 | +We'll set up `chef-client` to run as a service under runit, such as is | ||
159 | +done in the `chef-client` cookbook. This example will be more simple | ||
160 | +than in that cookbook. First, create the required run template, | ||
161 | +`chef-client/templates/default/sv-chef-client-run.erb`. | ||
162 | + | ||
163 | + #!/bin/sh | ||
164 | + exec 2>&1 | ||
165 | + exec /usr/bin/env chef-client -i 1800 -s 30 | ||
166 | + | ||
167 | +Then create the required log/run template, | ||
168 | +`chef-client/templates/default/sv-chef-client-run.erb`. | ||
169 | + | ||
170 | + #!/bin/sh | ||
171 | + exec svlogd -tt ./main | ||
172 | + | ||
173 | +__Note__ This will cause output of the running process to go to | ||
174 | +`/etc/sv/chef-client/log/main/current`. | ||
175 | + | ||
176 | +Finally, set up the service in the `chef-client` recipe with: | ||
177 | + | ||
178 | + runit_service "chef-client" | ||
179 | + | ||
180 | +Next, let's set up memcached with some additional options. First, the | ||
181 | +`memcached/templates/default/sv-memcached-run.erb` template: | ||
182 | + | ||
183 | + #!/bin/sh | ||
184 | + exec 2>&1 | ||
185 | + exec chpst -u <%= @options[:user] %> /usr/bin/memcached -v -m <%= @options[:memory] %> -p <%= @options[:port] %> | ||
186 | + | ||
187 | +Note that the script uses chpst (which comes with runit) to set the | ||
188 | +user option, then starts memcached on the specified memory and port | ||
189 | +(see below). | ||
190 | + | ||
191 | +The log/run template, | ||
192 | +`memcached/templates/default/sv-memcached-log-run.erb`: | ||
193 | + | ||
194 | + #!/bin/sh | ||
195 | + exec svlogd -tt ./main | ||
196 | + | ||
197 | +Finally, the `runit_service` in our recipe: | ||
198 | + | ||
199 | + runit_service "memcached" do | ||
200 | + options({ | ||
201 | + :memory => node[:memcached][:memory], | ||
202 | + :port => node[:memcached][:port], | ||
203 | + :user => node[:memcached][:user]}.merge(params) | ||
204 | + ) | ||
205 | + end | ||
206 | + | ||
207 | +This is where the user, port and memory options used in the run | ||
208 | +template are used. | ||
209 | + | ||
210 | +License and Author | ||
211 | +================== | ||
212 | + | ||
213 | +Author:: Adam Jacob <adam@opscode.com> | ||
214 | +Author:: Joshua Timberman <joshua@opscode.com> | ||
215 | + | ||
216 | +Copyright:: 2008-2011, Opscode, Inc | ||
217 | + | ||
218 | +Licensed under the Apache License, Version 2.0 (the "License"); | ||
219 | +you may not use this file except in compliance with the License. | ||
220 | +You may obtain a copy of the License at | ||
221 | + | ||
222 | + http://www.apache.org/licenses/LICENSE-2.0 | ||
223 | + | ||
224 | +Unless required by applicable law or agreed to in writing, software | ||
225 | +distributed under the License is distributed on an "AS IS" BASIS, | ||
226 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
227 | +See the License for the specific language governing permissions and | ||
228 | +limitations under the License. |
@@ -0,0 +1,24 @@ | @@ -0,0 +1,24 @@ | ||
1 | +# | ||
2 | +# Cookbook Name:: runit | ||
3 | +# Attribute File:: sv_bin | ||
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 | +default[:runit][:sv_bin] = "/opt/gitlab/embedded/bin/sv" | ||
21 | +default[:runit][:chpst_bin] = "/opt/gitlab/embedded/bin/chpst" | ||
22 | +default[:runit][:service_dir] = "/opt/gitlab/service" | ||
23 | +default[:runit][:sv_dir] = "/opt/gitlab/sv" | ||
24 | + |
files/gitlab-cookbooks/runit/definitions/runit_service.rb
0 → 100644
@@ -0,0 +1,193 @@ | @@ -0,0 +1,193 @@ | ||
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, :directory => nil, :only_if => false, :finish_script => false, :control => [], :run_restart => true, :active_directory => nil, :init_script_template => nil, :owner => "root", :group => "root", :template_name => nil, :start_command => "start", :stop_command => "stop", :restart_command => "restart", :status_command => "status", :options => Hash.new, :env => Hash.new, :action => :enable, :down => false do | ||
21 | + | ||
22 | + include_recipe "runit" | ||
23 | + | ||
24 | + params[:directory] ||= node[:runit][:sv_dir] | ||
25 | + params[:active_directory] ||= node[:runit][:service_dir] | ||
26 | + params[:template_name] ||= params[:name] | ||
27 | + | ||
28 | + sv_dir_name = "#{params[:directory]}/#{params[:name]}" | ||
29 | + service_dir_name = "#{params[:active_directory]}/#{params[:name]}" | ||
30 | + params[:options].merge!(:env_dir => "#{sv_dir_name}/env") unless params[:env].empty? | ||
31 | + | ||
32 | + case params[:action] | ||
33 | + when :enable | ||
34 | + | ||
35 | + | ||
36 | + directory sv_dir_name do | ||
37 | + owner params[:owner] | ||
38 | + group params[:group] | ||
39 | + mode 0755 | ||
40 | + action :create | ||
41 | + end | ||
42 | + | ||
43 | + directory "#{sv_dir_name}/log" do | ||
44 | + owner params[:owner] | ||
45 | + group params[:group] | ||
46 | + mode 0755 | ||
47 | + action :create | ||
48 | + end | ||
49 | + | ||
50 | + directory "#{sv_dir_name}/log/main" do | ||
51 | + owner params[:owner] | ||
52 | + group params[:group] | ||
53 | + mode 0755 | ||
54 | + action :create | ||
55 | + end | ||
56 | + | ||
57 | + template "#{sv_dir_name}/run" do | ||
58 | + owner params[:owner] | ||
59 | + group params[:group] | ||
60 | + mode 0755 | ||
61 | + source "sv-#{params[:template_name]}-run.erb" | ||
62 | + cookbook params[:cookbook] if params[:cookbook] | ||
63 | + if params[:options].respond_to?(:has_key?) | ||
64 | + variables :options => params[:options] | ||
65 | + end | ||
66 | + end | ||
67 | + | ||
68 | + template "#{sv_dir_name}/log/run" do | ||
69 | + owner params[:owner] | ||
70 | + group params[:group] | ||
71 | + mode 0755 | ||
72 | + source "sv-#{params[:template_name]}-log-run.erb" | ||
73 | + cookbook params[:cookbook] if params[:cookbook] | ||
74 | + if params[:options].respond_to?(:has_key?) | ||
75 | + variables :options => params[:options] | ||
76 | + end | ||
77 | + end | ||
78 | + | ||
79 | + if params[:down] | ||
80 | + file "#{sv_dir_name}/down" do | ||
81 | + mode "0644" | ||
82 | + end | ||
83 | + else | ||
84 | + file "#{sv_dir_name}/down" do | ||
85 | + action :delete | ||
86 | + end | ||
87 | + end | ||
88 | + | ||
89 | + unless params[:env].empty? | ||
90 | + directory "#{sv_dir_name}/env" do | ||
91 | + mode 0755 | ||
92 | + action :create | ||
93 | + end | ||
94 | + | ||
95 | + params[:env].each do |var, value| | ||
96 | + file "#{sv_dir_name}/env/#{var}" do | ||
97 | + content value | ||
98 | + end | ||
99 | + end | ||
100 | + end | ||
101 | + | ||
102 | + if params[:finish_script] | ||
103 | + template "#{sv_dir_name}/finish" do | ||
104 | + owner params[:owner] | ||
105 | + group params[:group] | ||
106 | + mode 0755 | ||
107 | + source "sv-#{params[:template_name]}-finish.erb" | ||
108 | + cookbook params[:cookbook] if params[:cookbook] | ||
109 | + if params[:options].respond_to?(:has_key?) | ||
110 | + variables :options => params[:options] | ||
111 | + end | ||
112 | + end | ||
113 | + end | ||
114 | + | ||
115 | + unless params[:control].empty? | ||
116 | + directory "#{sv_dir_name}/control" do | ||
117 | + owner params[:owner] | ||
118 | + group params[:group] | ||
119 | + mode 0755 | ||
120 | + action :create | ||
121 | + end | ||
122 | + | ||
123 | + params[:control].each do |signal| | ||
124 | + template "#{sv_dir_name}/control/#{signal}" do | ||
125 | + owner params[:owner] | ||
126 | + group params[:group] | ||
127 | + mode 0755 | ||
128 | + source "sv-#{params[:template_name]}-control-#{signal}.erb" | ||
129 | + cookbook params[:cookbook] if params[:cookbook] | ||
130 | + if params[:options].respond_to?(:has_key?) | ||
131 | + variables :options => params[:options] | ||
132 | + end | ||
133 | + end | ||
134 | + end | ||
135 | + end | ||
136 | + | ||
137 | + if params[:init_script_template] | ||
138 | + template "/opt/gitlab/init/#{params[:name]}" do | ||
139 | + owner params[:owner] | ||
140 | + group params[:group] | ||
141 | + mode 0755 | ||
142 | + source params[:init_script_template] | ||
143 | + if params[:options].respond_to?(:has_key?) | ||
144 | + variables :options => params[:options] | ||
145 | + end | ||
146 | + end | ||
147 | + else | ||
148 | + if params[:active_directory] == node[:runit][:service_dir] | ||
149 | + link "/opt/gitlab/init/#{params[:name]}" do | ||
150 | + to node[:runit][:sv_bin] | ||
151 | + end | ||
152 | + end | ||
153 | + end | ||
154 | + | ||
155 | + unless node[:platform] == "gentoo" | ||
156 | + link service_dir_name do | ||
157 | + to sv_dir_name | ||
158 | + end | ||
159 | + end | ||
160 | + | ||
161 | + ruby_block "supervise_#{params[:name]}_sleep" do | ||
162 | + block do | ||
163 | + Chef::Log.debug("Waiting until named pipe #{sv_dir_name}/supervise/ok exists.") | ||
164 | + until ::FileTest.pipe?("#{sv_dir_name}/supervise/ok") do | ||
165 | + sleep 1 | ||
166 | + Chef::Log.debug(".") | ||
167 | + end | ||
168 | + end | ||
169 | + not_if { FileTest.pipe?("#{sv_dir_name}/supervise/ok") } | ||
170 | + end | ||
171 | + | ||
172 | + service params[:name] do | ||
173 | + control_cmd = node[:runit][:sv_bin] | ||
174 | + if params[:owner] | ||
175 | + control_cmd = "#{node[:runit][:chpst_bin]} -u #{params[:owner]} #{control_cmd}" | ||
176 | + end | ||
177 | + provider Chef::Provider::Service::Simple | ||
178 | + supports :restart => true, :status => true | ||
179 | + start_command "#{control_cmd} #{params[:start_command]} #{service_dir_name}" | ||
180 | + stop_command "#{control_cmd} #{params[:stop_command]} #{service_dir_name}" | ||
181 | + restart_command "#{control_cmd} #{params[:restart_command]} #{service_dir_name}" | ||
182 | + status_command "#{control_cmd} #{params[:status_command]} #{service_dir_name}" | ||
183 | + if params[:run_restart] && OmnibusHelper.should_notify?(params[:name]) | ||
184 | + subscribes :restart, resources(:template => "#{sv_dir_name}/run"), :delayed | ||
185 | + end | ||
186 | + action :nothing | ||
187 | + end | ||
188 | + when :disable | ||
189 | + link service_dir_name do | ||
190 | + action :delete | ||
191 | + end | ||
192 | + end | ||
193 | +end |
files/gitlab-cookbooks/runit/files/default/gitlab-runsvdir.conf
0 → 100644
@@ -0,0 +1,10 @@ | @@ -0,0 +1,10 @@ | ||
1 | +start on runlevel [2345] | ||
2 | +stop on shutdown | ||
3 | +respawn | ||
4 | +post-stop script | ||
5 | + # To avoid stomping on runsv's owned by a different runsvdir | ||
6 | + # process, kill any runsv process that has been orphaned, and is | ||
7 | + # now owned by init (process 1). | ||
8 | + pkill -HUP -P 1 runsv$ | ||
9 | +end script | ||
10 | +exec /opt/gitlab/embedded/bin/runsvdir-start |
@@ -0,0 +1,37 @@ | @@ -0,0 +1,37 @@ | ||
1 | +maintainer "Opscode, Inc." | ||
2 | +maintainer_email "cookbooks@opscode.com" | ||
3 | +license "Apache 2.0" | ||
4 | +description "Installs runit and provides runit_service definition" | ||
5 | +version "0.14.2" | ||
6 | + | ||
7 | +recipe "runit", "Installs and configures runit" | ||
8 | + | ||
9 | +%w{ ubuntu debian gentoo }.each do |os| | ||
10 | + supports os | ||
11 | +end | ||
12 | + | ||
13 | +attribute "runit", | ||
14 | + :display_name => "Runit", | ||
15 | + :description => "Hash of runit attributes", | ||
16 | + :type => "hash" | ||
17 | + | ||
18 | +attribute "runit/sv_bin", | ||
19 | + :display_name => "Runit sv bin", | ||
20 | + :description => "Location of the sv binary", | ||
21 | + :default => "/usr/bin/sv" | ||
22 | + | ||
23 | +attribute "runit/chpst_bin", | ||
24 | + :display_name => "Runit chpst bin", | ||
25 | + :description => "Location of the chpst binary", | ||
26 | + :default => "/usr/bin/chpst" | ||
27 | + | ||
28 | +attribute "runit/service_dir", | ||
29 | + :display_name => "Runit service directory", | ||
30 | + :description => "Symlinks to services managed under runit", | ||
31 | + :default => "/etc/service" | ||
32 | + | ||
33 | +attribute "runit/sv_dir", | ||
34 | + :display_name => "Runit sv directory", | ||
35 | + :description => "Location of services managed by runit", | ||
36 | + :default => "/etc/sv" | ||
37 | + |
@@ -0,0 +1,32 @@ | @@ -0,0 +1,32 @@ | ||
1 | +# | ||
2 | +# Cookbook Name:: runit | ||
3 | +# Recipe:: default | ||
4 | +# | ||
5 | +# Copyright 2008-2010, 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 | +# TODO: This needs RHEL support | ||
21 | +case node["platform"] | ||
22 | +when "ubuntu" | ||
23 | + include_recipe "runit::upstart" | ||
24 | +when "redhat","centos","rhel","scientific" | ||
25 | + if node['platform_version'] =~ /^6/ | ||
26 | + include_recipe "runit::upstart" | ||
27 | + else | ||
28 | + include_recipe "runit::sysvinit" | ||
29 | + end | ||
30 | +else | ||
31 | + include_recipe "runit::sysvinit" | ||
32 | +end |
@@ -0,0 +1,29 @@ | @@ -0,0 +1,29 @@ | ||
1 | +# | ||
2 | +# Cookbook Name:: runit | ||
3 | +# Recipe:: sysvinit | ||
4 | +# | ||
5 | +# Copyright 2011, 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 | +# We assume you are sysvinit | ||
21 | +svdir_line = 'CS:123456:respawn:/opt/gitlab/embedded/bin/runsvdir-start' | ||
22 | +execute "echo '#{svdir_line}' >> /etc/inittab" do | ||
23 | + not_if "grep '#{svdir_line}' /etc/inittab" | ||
24 | + notifies :run, "execute[init q]", :immediately | ||
25 | +end | ||
26 | + | ||
27 | +execute "init q" do | ||
28 | + action :nothing | ||
29 | +end |
@@ -0,0 +1,47 @@ | @@ -0,0 +1,47 @@ | ||
1 | +# | ||
2 | +# Cookbook Name:: runit | ||
3 | +# Recipe:: default | ||
4 | +# | ||
5 | +# Copyright 2008-2010, 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 | +# Ensure the previous named iteration of the system job is nuked | ||
21 | +execute "initctl stop gitlab-runsvdir" do | ||
22 | + only_if "initctl status gitlab-runsvdir | grep start" | ||
23 | + retries 30 | ||
24 | +end | ||
25 | +file "/etc/init/gitlab-runsvdir.conf" do | ||
26 | + action :delete | ||
27 | +end | ||
28 | + | ||
29 | +cookbook_file "/etc/init/gitlab-runsvdir.conf" do | ||
30 | + owner "root" | ||
31 | + group "root" | ||
32 | + mode "0644" | ||
33 | + source "gitlab-runsvdir.conf" | ||
34 | +end | ||
35 | + | ||
36 | +# Keep on trying till the job is found :( | ||
37 | +execute "initctl status gitlab-runsvdir" do | ||
38 | + retries 30 | ||
39 | +end | ||
40 | + | ||
41 | +# If we are stop/waiting, start | ||
42 | +# | ||
43 | +# Why, upstart, aren't you idempotent? :( | ||
44 | +execute "initctl start gitlab-runsvdir" do | ||
45 | + only_if "initctl status gitlab-runsvdir | grep stop" | ||
46 | + retries 30 | ||
47 | +end |
files/gitlab-cookbooks/solo.rb