Class: DropGit::Daemon
- Inherits:
-
Object
- Object
- DropGit::Daemon
- Defined in:
- lib/dropgit/daemon.rb
Instance Method Summary collapse
-
#initialize ⇒ Daemon
constructor
A new instance of Daemon.
-
#run ⇒ Object
run.
-
#start ⇒ Object
start daemon.
- #stop ⇒ Object
Constructor Details
#initialize ⇒ Daemon
Returns a new instance of Daemon.
7 8 9 10 11 12 |
# File 'lib/dropgit/daemon.rb', line 7 def initialize @repositories = [] DropGit.settings.repositories.each do |data| @repositories << Repository.new(data) end end |
Instance Method Details
#run ⇒ Object
run
15 16 17 18 19 20 |
# File 'lib/dropgit/daemon.rb', line 15 def run loop do @repositories.each { |r| r.update } sleep 1 end end |
#start ⇒ Object
start daemon
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/dropgit/daemon.rb', line 23 def start raise "DropGit daemon already started" if is_running Daemons.daemonize({ :app_name => 'dropgit', :dir_mode => :normal, :dir => DropGit.settings.daemon_dir, :log_output => true }) run end |
#stop ⇒ Object
34 35 36 37 |
# File 'lib/dropgit/daemon.rb', line 34 def stop raise "DropGit daemon is already stopped" unless File.exists?(pid_file) Process.kill("INT", pid) end |