Sha256: 91ebc518961f36ecb0439dfd3174f1b0d78f7e0dd4c53d40f64e4a7df05b6f51
Contents?: true
Size: 1.19 KB
Versions: 1
Compression:
Stored size: 1.19 KB
Contents
require 'structure_mapper' require 'childprocess' module RegenwolkeAutons class NginxAuton include StructureMapper::Hash attribute pid: Fixnum attribute stdout: String attribute stderr: String attr_accessor :context def start context.schedule_step(:start_nginx_if_not_running) context.schedule_repeating_delayed_step 10, 10, :start_nginx_if_not_running end def start_nginx create_config cp = ChildProcess.build('nginx', '-p', '.', '-c', 'nginx.config') cp.detach = true cp.start self.pid = cp.pid end def start_nginx_if_not_running context.schedule_step(:start_nginx) unless nginx_process_exist? end private def nginx_process_exist? if pid begin Process.getpgid( pid ) true rescue Errno::ESRCH false end else false end end def create_config applications={'regenwolke' => [['localhost',ENV['PORT'] || 5000]]} erb = ERB.new File.read(File.expand_path('../nginx_config.erb', __FILE__)) File.write("nginx.config",erb.result(binding)) end end Nestene::Registry.register_auton(NginxAuton) end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
regenwolke_autons-0.0.8 | lib/regenwolke_autons/nginx_auton.rb |