Class: BatchManager::Daemon

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/batch_manager/daemon.rb

Defined Under Namespace

Classes: Spawn

Class Method Summary collapse

Methods included from Utils

included

Class Method Details

.pid_file_path(batch_name, is_wet = false) ⇒ Object



19
20
21
22
# File 'lib/batch_manager/daemon.rb', line 19

def pid_file_path(batch_name, is_wet = false)
  pid_file_name = is_wet ? "#{batch_name}_wet" : batch_name
  File.join(BatchManager.log_dir, pid_file_name) + ".pid"
end

.spawn(command, batch_file, options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/batch_manager/daemon.rb', line 8

def spawn(command, batch_file, options = {})
  daemon_options = {
    working_dir: Rails.root.to_s,
    pid_file: pid_file_path(batch_name(batch_file), options[:wet]),
    log_file: BatchManager::Logger.log_file_path(batch_name(batch_file), options[:wet]),
    sync_log: true
  }
  FileUtils.mkdir_p(File.dirname(daemon_options[:pid_file]), :mode => 0775)
  Spawn.spawn!(daemon_options, [command, batch_file, options])
end