Class: SimpleDaemonize
- Inherits:
-
Object
- Object
- SimpleDaemonize
- Defined in:
- lib/shared/simple_daemonize.rb
Class Method Summary collapse
Class Method Details
.start(proc, pid_path, app_name) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/shared/simple_daemonize.rb', line 6 def self.start(proc, pid_path, app_name) working_dir = Dir.pwd group = Daemons::ApplicationGroup.new(app_name) group.new_application(:mode => :none).start File.open(pid_path, 'w') { |file| file.write(Process.pid) } Dir.chdir(working_dir) proc.call end |
.stop(pid_path) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/shared/simple_daemonize.rb', line 17 def self.stop(pid_path) return unless File.exists?(pid_path) pid = File.read(pid_path) system "kill -9 #{pid} &> /dev/null" system "rm #{pid_path} &> /dev/null" end |