class RegenwolkeAutons::NginxAuton
Attributes
context[RW]
Public Instance Methods
start()
click to toggle source
# File lib/regenwolke_autons/nginx_auton.rb, line 16 def start context.schedule_step(:start_nginx_if_not_running) context.schedule_repeating_delayed_step 10, 10, :start_nginx_if_not_running end
start_nginx()
click to toggle source
# File lib/regenwolke_autons/nginx_auton.rb, line 21 def start_nginx create_config cp = ChildProcess.build('nginx', '-p', 'regenwolke/nginx', '-c', 'nginx.config') cp.detach = true cp.start self.pid = cp.pid end
start_nginx_if_not_running()
click to toggle source
# File lib/regenwolke_autons/nginx_auton.rb, line 30 def start_nginx_if_not_running context.schedule_step(:start_nginx) unless nginx_process_exist? end
Private Instance Methods
create_config()
click to toggle source
# File lib/regenwolke_autons/nginx_auton.rb, line 49 def create_config applications={'regenwolke' => [['localhost',ENV['PORT'] || 5000]]} erb = ERB.new File.read(File.expand_path('../nginx_config.erb', __FILE__)) File.write("regenwolke/nginx/nginx.config",erb.result(binding)) end
nginx_process_exist?()
click to toggle source
# File lib/regenwolke_autons/nginx_auton.rb, line 36 def nginx_process_exist? if pid begin Process.getpgid( pid ) true rescue Errno::ESRCH false end else false end end