Class: WarehouseSupervisor::Main
- Inherits:
-
Object
- Object
- WarehouseSupervisor::Main
- Defined in:
- lib/warehouse_supervisor/main.rb
Instance Method Summary collapse
- #generate_contents ⇒ Object
-
#initialize(erb_file, options = {}) ⇒ Main
constructor
A new instance of Main.
- #start ⇒ Object
Constructor Details
#initialize(erb_file, options = {}) ⇒ Main
Returns a new instance of Main.
7 8 9 10 |
# File 'lib/warehouse_supervisor/main.rb', line 7 def initialize(erb_file, ={}) @erb_file = erb_file @options = end |
Instance Method Details
#generate_contents ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/warehouse_supervisor/main.rb', line 12 def generate_contents unless File.exist?(@options[:config]) STDERR.puts "Bad file '#{@options[:config]}'" exit 1 end unless File.exist?(@erb_file) STDERR.puts "Bad file '#{@erb_file}'" exit 1 end definitions = YAML.load(File.read(@options[:config]))[@options[:group].to_s] unless definitions STDERR.puts "Bad group '#{@options[:group]}'" exit 1 end erb_content = File.read(@erb_file) Renderer.new(definitions, erb_content).render end |
#start ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/warehouse_supervisor/main.rb', line 30 def start Tempfile.open("supervisord.conf") do |f| Tempfile.open("supervisord.log") do |l| f.puts "[supervisord]" f.puts "nodaemon = true" f.puts "logfile = #{l.path}" f.puts "loglevel = debug" f.write self.generate_contents f.flush command = "supervisord -c '#{f.path}'" puts command exec command end end end |