Commit e2695699aca79196a37c8a461037159eba6e46a6
1 parent
fce35f94
Exists in
master
and in
13 other branches
Vendor the runit software definition
Source: https://github.com/opscode/omnibus-software/blob/0dddef2baefd5f62dd38ff2ae6e5491bfb394479/config/software/runit.rb
Showing
1 changed file
with
114 additions
and
0 deletions
Show diff stats
@@ -0,0 +1,114 @@ | @@ -0,0 +1,114 @@ | ||
1 | +# | ||
2 | +# Copyright:: Copyright (c) 2012-2014 Chef Software, Inc. | ||
3 | +# License:: Apache License, Version 2.0 | ||
4 | +# | ||
5 | +# Licensed under the Apache License, Version 2.0 (the "License"); | ||
6 | +# you may not use this file except in compliance with the License. | ||
7 | +# You may obtain a copy of the License at | ||
8 | +# | ||
9 | +# http://www.apache.org/licenses/LICENSE-2.0 | ||
10 | +# | ||
11 | +# Unless required by applicable law or agreed to in writing, software | ||
12 | +# distributed under the License is distributed on an "AS IS" BASIS, | ||
13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
14 | +# See the License for the specific language governing permissions and | ||
15 | +# limitations under the License. | ||
16 | +# | ||
17 | + | ||
18 | +name "runit" | ||
19 | +default_version "2.1.1" | ||
20 | + | ||
21 | +source :url => "http://smarden.org/runit/runit-2.1.1.tar.gz", | ||
22 | + :md5 => "8fa53ea8f71d88da9503f62793336bc3" | ||
23 | + | ||
24 | +relative_path "admin" | ||
25 | + | ||
26 | +working_dir = "#{project_dir}/runit-2.1.1" | ||
27 | + | ||
28 | +build do | ||
29 | + # put runit where we want it, not where they tell us to | ||
30 | + command 'sed -i -e "s/^char\ \*varservice\ \=\"\/service\/\";$/char\ \*varservice\ \=\"' + project.install_path.gsub("/", "\\/") + '\/service\/\";/" src/sv.c', :cwd => working_dir | ||
31 | + # TODO: the following is not idempotent | ||
32 | + command "sed -i -e s:-static:: src/Makefile", :cwd => working_dir | ||
33 | + | ||
34 | + # build it | ||
35 | + command "make", :cwd => "#{working_dir}/src" | ||
36 | + command "make check", :cwd => "#{working_dir}/src" | ||
37 | + | ||
38 | + # move it | ||
39 | + command "mkdir -p #{install_dir}/embedded/bin" | ||
40 | + ["src/chpst", | ||
41 | + "src/runit", | ||
42 | + "src/runit-init", | ||
43 | + "src/runsv", | ||
44 | + "src/runsvchdir", | ||
45 | + "src/runsvdir", | ||
46 | + "src/sv", | ||
47 | + "src/svlogd", | ||
48 | + "src/utmpset"].each do |bin| | ||
49 | + command "cp #{bin} #{install_dir}/embedded/bin", :cwd => working_dir | ||
50 | + end | ||
51 | + | ||
52 | + block do | ||
53 | + install_path = self.project.install_path | ||
54 | + open("#{install_dir}/embedded/bin/runsvdir-start", "w") do |file| | ||
55 | + file.print <<-EOH | ||
56 | +#!/bin/bash | ||
57 | +# | ||
58 | +# Copyright:: Copyright (c) 2012-2014 Chef Software, Inc. | ||
59 | +# License:: Apache License, Version 2.0 | ||
60 | +# | ||
61 | +# Licensed under the Apache License, Version 2.0 (the "License"); | ||
62 | +# you may not use this file except in compliance with the License. | ||
63 | +# You may obtain a copy of the License at | ||
64 | +# | ||
65 | +# http://www.apache.org/licenses/LICENSE-2.0 | ||
66 | +# | ||
67 | +# Unless required by applicable law or agreed to in writing, software | ||
68 | +# distributed under the License is distributed on an "AS IS" BASIS, | ||
69 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
70 | +# See the License for the specific language governing permissions and | ||
71 | +# limitations under the License. | ||
72 | +# | ||
73 | + | ||
74 | +PATH=#{install_path}/bin:#{install_path}/embedded/bin:/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin | ||
75 | + | ||
76 | +# enforce our own ulimits | ||
77 | + | ||
78 | +ulimit -c 0 | ||
79 | +ulimit -d unlimited | ||
80 | +ulimit -e 0 | ||
81 | +ulimit -f unlimited | ||
82 | +ulimit -i 62793 | ||
83 | +ulimit -l 64 | ||
84 | +ulimit -m unlimited | ||
85 | +# WARNING: increasing the global file descriptor limit increases RAM consumption on startup dramatically | ||
86 | +ulimit -n 50000 | ||
87 | +ulimit -q 819200 | ||
88 | +ulimit -r 0 | ||
89 | +ulimit -s 10240 | ||
90 | +ulimit -t unlimited | ||
91 | +ulimit -u unlimited | ||
92 | +ulimit -v unlimited | ||
93 | +ulimit -x unlimited | ||
94 | +echo "1000000" > /proc/sys/fs/file-max | ||
95 | + | ||
96 | +# and our ulimit | ||
97 | + | ||
98 | +umask 022 | ||
99 | + | ||
100 | +exec env - PATH=$PATH \ | ||
101 | +runsvdir -P #{install_path}/service 'log: ...........................................................................................................................................................................................................................................................................................................................................................................................................' | ||
102 | + EOH | ||
103 | + end | ||
104 | + end | ||
105 | + | ||
106 | + command "chmod 755 #{install_dir}/embedded/bin/runsvdir-start" | ||
107 | + | ||
108 | + # set up service directories | ||
109 | + ["#{install_dir}/service", | ||
110 | + "#{install_dir}/sv", | ||
111 | + "#{install_dir}/init"].each do |dir| | ||
112 | + command "mkdir -p #{dir}" | ||
113 | + end | ||
114 | +end |