-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforeman.rb
45 lines (42 loc) · 1.64 KB
/
foreman.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
dep 'foreman', :app_path, :use_faye, :web_server do
foreman_in_gemfile = shell? %{grep "foreman" Gemfile}, :cd => app_path
met? {
Babushka::Renderable.new(app_path / "Procfile.production").from?(dependency.load_path.parent / "foreman/Procfile.production.erb") &&
foreman_in_gemfile
}
meet {
render_erb "foreman/Procfile.production.erb", :to => (app_path / "Procfile.production").to_s
cd app_path do
shell %{echo 'gem "foreman"' >> Gemfile}
shell %{echo 'gem "foreman-export-initscript", :github => "webgradus/foreman-export-initscript"' >> Gemfile}
log "bundle install..."
rvm_shell %{bundle install}
end
foreman_in_gemfile = shell? %{grep "foreman" Gemfile}, :cd => app_path
}
end
dep 'foreman.export', :app_path, :use_faye, :web_server do
requires 'foreman'.with(app_path, use_faye, web_server)
app_name = app_path.to_s.split("/")[-1]
met? {
"/etc/init.d/#{app_name}".p.exists?
}
meet {
cd app_path do
rvm_shell "bundle exec foreman export initscript /etc/init.d -f ./Procfile.production -a #{app_name} -u root -l /opt/#{app_name}/log"
#rvm_run_with_ruby "2.0.0", "bundle exec foreman export upstart /etc/init -f ./Procfile.production -a #{app_name} -u root -l /opt/#{app_name}/log"
shell "chmod 755 /etc/init.d/#{app_name}"
end
}
end
dep 'foreman.start', :app_path, :use_faye, :web_server do
requires 'foreman.export'.with(app_path, use_faye, web_server)
app_name = app_path.to_s.split("/")[-1]
met? {
"/run/#{app_name}/web.1.pid".p.exists?
}
meet {
shell "/etc/init.d/#{app_name} start"
#shell "foreman start -f ./Procfile.production"
}
end