我需要运行一个独立的 ruby 脚本作为 Unix (linux) 守护进程。
运行该守护程序后,我需要使用它运行另一个 Ruby 方法。
我ruby-daemon
使用gem install daemon
.
我做了测试守护程序。
我的 test.rb 文件是:
module Test
def test_method
@s =" ITS WORKING !"
file=File.new("/home/username/test.txt", "w")
file.puts @s
file.close
end
end
我的 test_control.rb 文件是:
# this is myserver_control.rb
require 'rubygems' # if you use RubyGems
require 'daemons'
Daemons.run('test.rb')
在此之后,我运行以下命令:ruby test_control.rb start
现在如何检查守护程序是否已正常启动?
如何使用它调用方法?