Permalink
Browse files

daemonized build_checker

  • Loading branch information...
1 parent b913291 commit 785e47de6f920125ba96afe269fdb7f583241d83 @jimarnold jimarnold committed Aug 23, 2012
Showing with 41 additions and 12 deletions.
  1. +3 −1 lib/rails_on_fire.rb
  2. +38 −11 script/check_build.rb
@@ -1,8 +1,10 @@
require 'selenium/webdriver'
class RailsOnFire
- def initialize driver
+ def initialize driver, user, password
@driver = driver
+ @user = user
+ @password = password
end
def log_in
View
@@ -1,20 +1,47 @@
#!/usr/bin/env ruby
require File.expand_path('../../config/application', __FILE__)
-
+require 'daemons'
require 'selenium/webdriver'
require 'rails_on_fire'
require 'build_checker'
-$rof_user = ENV['ROF_USER']
-$rof_password = ENV['ROF_PASSWORD']
+def start
+ demonize
+ log("build checker is now started")
+end
+
+def stop
+ demonize
+ log "build checker is now stopped"
+end
+
+def demonize
+ Daemons.run_proc('build_checker', :dir_mode => :normal, :dir => '/var/tmp/', :monitor => false) do
+
+ rof_user = ENV['ROF_USER']
+ rof_password = ENV['ROF_PASSWORD']
+
+ raise "You need to set ROF_USER and ROF_PASSWORD env vars" if !rof_user || !rof_password
+
+ begin
+ d = Selenium::WebDriver.for :chrome
+ rof = RailsOnFire.new d, rof_user, rof_password
+ BuildChecker.new(rof, VictoryKitChat).run
+ ensure
+ d.quit
+ end
+ end
+end
+
+case ARGV[0]
+ when 'start'
+ start
+ when 'stop'
+ stop
+ else
+ puts "usage: check_build start|stop"
+end
+
-raise "You need to set ROF_USER and ROF_PASSWORD env vars" if !$rof_user || !$rof_password
-begin
- d = Selenium::WebDriver.for :chrome
- rof = RailsOnFire.new d
- BuildChecker.new(rof, VictoryKitChat).run
-ensure
- d.quit
-end

0 comments on commit 785e47d

Please sign in to comment.