Class: Foreman::Export::Systemd
- Defined in:
- lib/foreman/export/systemd.rb
Instance Attribute Summary
Attributes inherited from Base
#engine, #formation, #location, #options, #port
Instance Method Summary collapse
Methods inherited from Base
#app, #initialize, #log, procfile, #run, #template, #user
Constructor Details
This class inherits a constructor from Foreman::Export::Base
Instance Method Details
#export ⇒ Object
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 |
# File 'lib/foreman/export/systemd.rb', line 6 def export super Dir["#{location}/#{app}*.target"] .concat(Dir["#{location}/#{app}*.service"]) .concat(Dir["#{location}/#{app}*.target.wants/#{app}*.service"]) .each do |file| clean file end Dir["#{location}/#{app}*.target.wants"].each do |file| clean_dir file end process_master_names = [] engine.each_process do |name, process| service_fn = "#{app}-#{name}@.service" write_template "systemd/process.service.erb", service_fn, binding create_directory("#{app}-#{name}.target.wants") 1.upto(engine.formation[name]) .collect { |num| engine.port_for(process, num) } .collect { |port| "#{app}-#{name}@#{port}.service" } .each do |process_name| create_symlink("#{app}-#{name}.target.wants/#{process_name}", "../#{service_fn}") rescue Errno::EEXIST # This is needed because rr-mocks do not call the origial cleanup 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 |