Class: ForemanMonit::Exporter
- Inherits:
-
Object
- Object
- ForemanMonit::Exporter
- Defined in:
- lib/foreman-monit/exporter.rb
Instance Method Summary collapse
- #base_dir ⇒ Object
- #chruby_init ⇒ Object
- #info ⇒ Object
-
#initialize(options) ⇒ Exporter
constructor
A new instance of Exporter.
- #log_file(name) ⇒ Object
- #pid_file(name) ⇒ Object
- #port ⇒ Object
- #rails_env ⇒ Object
- #run! ⇒ Object
Constructor Details
#initialize(options) ⇒ Exporter
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/foreman-monit/exporter.rb', line 6 def initialize() @app = [:app] @user = [:user] @target = [:target] @env = [:env] @chruby = [:chruby] @procfile = [:procfile] @su = which_su @bash = which_bash @engine = Foreman::Engine.new load_procfile load_env @port = @engine.base_port end |
Instance Method Details
#base_dir ⇒ Object
49 50 51 |
# File 'lib/foreman-monit/exporter.rb', line 49 def base_dir Dir.getwd end |
#chruby_init ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/foreman-monit/exporter.rb', line 41 def chruby_init if @chruby "chruby #{@chruby} &&" else '' end end |
#info ⇒ Object
32 33 34 |
# File 'lib/foreman-monit/exporter.rb', line 32 def info puts @engine.processes.inspect end |
#log_file(name) ⇒ Object
57 58 59 |
# File 'lib/foreman-monit/exporter.rb', line 57 def log_file(name) File.(File.join(@target, "#{@app}-#{name}.log")) end |
#pid_file(name) ⇒ Object
53 54 55 |
# File 'lib/foreman-monit/exporter.rb', line 53 def pid_file(name) File.(File.join(@target, "#{@app}-#{name}.pid")) end |
#port ⇒ Object
36 37 38 39 |
# File 'lib/foreman-monit/exporter.rb', line 36 def port @port += 1 @port-1 end |
#rails_env ⇒ Object
61 62 63 |
# File 'lib/foreman-monit/exporter.rb', line 61 def rails_env @env end |
#run! ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/foreman-monit/exporter.rb', line 23 def run! Dir.mkdir(@target) unless File.exist?(@target) FileUtils.rm Dir.glob("#{@target}/*.conf") @engine.each_process do |name, process| file_name = File.join(@target, "#{@app}-#{name}.conf") File.open(file_name, 'w') { |f| f.write ERB.new(File.read(File.('../../../templates/monitrc.erb', __FILE__))).result(binding) } end end |