Ruby Gem守护程序-如何运行多个不同的守护程序

Ruby Gem守护程序-如何运行多个不同的守护程序,ruby,daemon,Ruby,Daemon,基本上,我只想在ruby脚本中运行几个守护进程: require 'daemons' Daemons.run path_1, { :ARGV => ['start'], :app_name => 'app1', :multiple => true, ... } Daemons.run path_2, { :ARGV => ['start'], :app_name => 'app2', :multiple => true, ... } 但是当ARGV[0]=

基本上,我只想在ruby脚本中运行几个守护进程:

require 'daemons'

Daemons.run path_1, { :ARGV => ['start'], :app_name => 'app1', :multiple => true, ... }
Daemons.run path_2, { :ARGV => ['start'], :app_name => 'app2', :multiple => true, ... }
但是当ARGV[0]='start'(与'status'/'stop'完美配合)时,永远不会调用第二个守护进程.run。正确的方法是什么?

来自

3-从另一个应用程序控制一组守护程序

布局:您有一个应用程序my_app.rb,它希望作为守护进程运行一系列服务器任务

# this is my_app.rb

require 'rubygems'        # if you use RubyGems
require 'daemons'

task1 = Daemons.call(:multiple => true) do
  # first server task

  loop {
    conn = accept_conn()
    serve(conn)
  }
end

task2 = Daemons.call do
  # second server task

  loop {
    something_different()
  }
end

# the parent process continues to run

# we can even control our tasks, for example stop them
task1.stop
task2.stop

exit
它合适吗