Class: RoDaemon::Data::Daemon

Inherits:
ActiveRecord::Base
  • Object
show all
Extended by:
Helper
Includes:
RoThor::Sh
Defined in:
lib/ro_daemon/data.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helper

logs_dir

Class Method Details

.create(*args, &blk) ⇒ Object



21
22
23
24
25
# File 'lib/ro_daemon/data.rb', line 21

def create(*args, &blk)
  r = super
  puts "create #{self}"
  r
end

.new(*args, &blk) ⇒ Object



14
15
16
17
18
19
# File 'lib/ro_daemon/data.rb', line 14

def new(*args, &blk)
    r = super
    r.stdout = logs_dir("#{r.id}.log")
    r.stderr = logs_dir("#{r.id}_err.log")
    r
end

Instance Method Details

#closed?(*args, &blk) ⇒ Boolean



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/ro_daemon/data.rb', line 30

def closed?(*args, &blk)
  begin
    sh "ps --pid #{pid}"
    true
  rescue ShErr => e
    if e.stdout.match(%r{PID TTY          TIME CMD\n})
      false
    else
      raise e
    end
  end
end