Sha256: 0e09c272f653fe2da5bfb70ef1a4578bf82315125933c49f428219cc42590dc0

Contents?: true

Size: 387 Bytes

Versions: 19

Compression:

Stored size: 387 Bytes

Contents

class SimpleDaemonize
  
  def self.start(proc, pid_path)    
    pid = fork { 
      STDOUT.reopen "/dev/null"
      proc.call
    }
    
    File.open(pid_path, 'w') { |file| file.write(pid) }
    pid
  end
  
  def self.stop(pid_path)
    return unless File.exists?(pid_path)
    system "kill #{File.read(pid_path)} &> /dev/null"
    system "rm #{pid_path} &> /dev/null"
  end
  
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
testbot-0.4.2 lib/shared/simple_daemonize.rb
testbot-0.4.1 lib/shared/simple_daemonize.rb
testbot-0.4.0 lib/shared/simple_daemonize.rb
testbot-0.3.9 lib/shared/simple_daemonize.rb
testbot-0.3.9.pre lib/shared/simple_daemonize.rb
testbot-0.3.8 lib/shared/simple_daemonize.rb
testbot-0.3.8.pre lib/shared/simple_daemonize.rb
testbot-0.3.7 lib/shared/simple_daemonize.rb
testbot-0.3.6 lib/shared/simple_daemonize.rb
testbot-0.3.5 lib/shared/simple_daemonize.rb
testbot-0.3.4 lib/shared/simple_daemonize.rb
testbot-0.3.3 lib/shared/simple_daemonize.rb
testbot-0.3.2 lib/shared/simple_daemonize.rb
testbot-0.3.1 lib/shared/simple_daemonize.rb
testbot-0.3.0 lib/shared/simple_daemonize.rb
testbot-0.2.9 lib/shared/simple_daemonize.rb
testbot-0.2.8 lib/shared/simple_daemonize.rb
testbot-0.2.7 lib/shared/simple_daemonize.rb
testbot-0.2.6 lib/shared/simple_daemonize.rb