Class: DropGit::Daemon

Inherits:
Object
  • Object
show all
Defined in:
lib/dropgit/daemon.rb

Instance Method Summary collapse

Constructor Details

#initializeDaemon

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

#runObject

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

#startObject

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

#stopObject



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