-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathpuma.rb
62 lines (49 loc) · 1.62 KB
/
puma.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
dep('puma on upstart') {
requires 'puma upstart config rendered'
}
dep('puma upstart config rendered') {
requires 'puma apps configured'
def config_path
'/etc/init'
end
def puma_config_path
config_path / 'puma.conf'
end
def puma_manager_config_path
config_path / 'puma-manager.conf'
end
met? {
Babushka::Renderable.new(puma_config_path).from?(dependency.load_path.parent / "puma/puma.conf.erb") &&
Babushka::Renderable.new(puma_manager_config_path).from?(dependency.load_path.parent / "puma/puma-manager.conf.erb")
}
meet {
render_erb dependency.load_path.parent / 'puma/puma.conf.erb', :to => puma_config_path, :sudo => true
render_erb dependency.load_path.parent / 'puma/puma-manager.conf.erb', :to => puma_manager_config_path, :sudo => true
}
}
dep('puma apps configured', :deployment_paths) {
deployment_paths.default(File.expand_path('~/current')).ask('Applications to run under Puma (paths separated by spaces)')
def puma_config_path
'/etc/puma.conf'
end
def app_paths
deployment_paths.to_s.split(' ').join("\n")
end
def renderable
Babushka::Renderable.new(puma_config_path)
end
def rendered_config
renderable.send(:render_erb, dependency.load_path.parent / 'puma/etc/puma.conf.erb', self)
end
met? {
require 'digest/sha1'
File.exists?(puma_config_path) &&
Digest::SHA1.hexdigest(rendered_config) == renderable.send(:sha_of, puma_config_path)
}
meet {
shell("cat > '#{renderable.path}'",
:input => renderable.send(:render_erb, dependency.load_path.parent / 'puma/etc/puma.conf.erb', self),
:sudo => true
)
}
}