diff options
author | Azul <azul@riseup.net> | 2012-09-19 11:00:29 +0200 |
---|---|---|
committer | Azul <azul@riseup.net> | 2012-09-19 11:00:29 +0200 |
commit | e8353821b846e676b85736d748cb923d8854884e (patch) | |
tree | 34e8c91e283182ce243c7107d6ccb67e10aa8c35 | |
parent | 2d124b74538f19681c619e4a807f60176ab2d869 (diff) |
deamonized script
you can now call it with
leap_ca.rb {start,restart,stop,run}
run will run in foreground.
-rwxr-xr-x[-rw-r--r--] | leap_ca.rb | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/leap_ca.rb b/leap_ca.rb index 57bf067..baefff2 100644..100755 --- a/leap_ca.rb +++ b/leap_ca.rb @@ -1,19 +1,21 @@ #!/usr/bin/ruby require 'rubygems' +require 'daemons' require 'yajl/http_stream' + require 'lib/cert' require 'lib/couch_stream' require 'lib/couch_changes' require 'lib/pool' -def main - puts "Tracking #{Cert.database.root}" - couch = CouchStream.new(Cert.database.root) - changes = CouchChanges.new(couch) - pool = LeapCA::Pool.new(File.expand_path("../config/pool.yml", __FILE__)) - pool.fill +puts "Tracking #{Cert.database.root}" +couch = CouchStream.new(Cert.database.root) +changes = CouchChanges.new(couch) +pool = LeapCA::Pool.new(File.expand_path("../config/pool.yml", __FILE__)) +pool.fill +Daemons.run_proc('leap_ca.rb') do changes.follow do |hash| p hash if hash[:deleted] @@ -21,5 +23,3 @@ def main end end end - -main |