Module: DreamhostPersonalBackup::StatusManager

Defined in:
lib/backup/status_manager.rb

Constant Summary collapse

PID_FILE =
'~/.dreamhost_personal_backup/running.pid'

Class Method Summary collapse

Class Method Details

.create_pid_fileObject



21
22
23
# File 'lib/backup/status_manager.rb', line 21

def self.create_pid_file
  File.open(File.expand_path(PID_FILE), "w") { |f| f.write(Process.pid) }
end

.is_backup_running?Boolean

Returns:

  • (Boolean)


7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/backup/status_manager.rb', line 7

def self.is_backup_running?
  pid_file = File.expand_path(PID_FILE)
  return false unless File.file?(pid_file)

  pid = File.open(pid_file).read.to_i

  begin
    Process.getpgid(pid)
    return true
  rescue Errno::ESRCH
    return false
  end
end

.remove_pid_fileObject



25
26
27
28
# File 'lib/backup/status_manager.rb', line 25

def self.remove_pid_file
  pid_file = File.expand_path(PID_FILE)
  File.delete(pid_file) if File.file?(pid_file)
end