How do I start a background process in Ruby? -


i'm having difficulties starting background process in ruby.

i've code right now.

#!/usr/bin/env ruby -w require "daemons" require 'rubygems'  path = "#{file.expand_path(file.dirname(__file__))}/.."  daemons.run_proc('stalker',{   :dir_mode => :normal,   :dir => "#{path}/tmp/pids",   :backtrace => true,   :monitor => false,   :log_output => true })   system "stalk #{path}/config/jobs.rb" end 

i start script using script/stalker start.

the problem can't stop it. saves wrong pid pid file.

like this:

script/stalker start => stalker: process pid **39756** started.  ps aux | grep ruby  => linus    **39781**   0,3  1,9  2522752  78864   ??  s     8:39pm   0:10.11 ruby stalk script/../config/jobs.rb 

why doesn't first pid match 1 printed using ps aux | grep ruby?

i've tried using exec, %x{} , 1 system run script.

if use run_proc, code want daemonized should go in block. starting process system doesn't make sense (it fork process (giving yet pid), , exec jobs.rb script. either move code jobs.rb run_proc block, or use daemons.run


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -