Skip to content

Commit

Permalink
Merge pull request #5 from phemmer/systemd-dependencies
Browse files Browse the repository at this point in the history
export: fix systemd dependencies
  • Loading branch information
dlage committed Mar 17, 2014
2 parents 37dcba0 + 67ffbe2 commit defc40b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
5 changes: 5 additions & 0 deletions data/export/systemd/master.target.erb
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
[Unit]
StopWhenUnneeded=true
Wants=<%= process_master_names.join(' ') %>

[Install]
WantedBy=multi-user.target
3 changes: 0 additions & 3 deletions data/export/systemd/process.service.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,3 @@ StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=%n
KillMode=process

[Install]
WantedBy=<%= app %>-<%= name %>.target
4 changes: 1 addition & 3 deletions data/export/systemd/process_master.target.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[Unit]
StopWhenUnneeded=true

[Install]
WantedBy=<%= app %>.target
Wants=<%= process_names.join(' ') %>
11 changes: 9 additions & 2 deletions lib/foreman/export/systemd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,23 @@ def export
clean file
end

write_template "systemd/master.target.erb", "#{app}.target", binding
process_master_names = []

engine.each_process do |name, process|
next if engine.formation[name] < 1
write_template "systemd/process_master.target.erb", "#{app}-#{name}.target", binding

process_names = []

1.upto(engine.formation[name]) do |num|
port = engine.port_for(process, num)
write_template "systemd/process.service.erb", "#{app}-#{name}-#{num}.service", binding
process_names << "#{app}-#{name}-#{num}.service"
end

write_template "systemd/process_master.target.erb", "#{app}-#{name}.target", binding
process_master_names << "#{app}-#{name}.target"
end

write_template "systemd/master.target.erb", "#{app}.target", binding
end
end

0 comments on commit defc40b

Please sign in to comment.