我寫了下面的Ruby守護進程執行代碼:紅寶石守護進程不會在系統啓動時
require 'rubygems'
require 'daemons'
pwd = File.dirname(File.expand_path(__FILE__))
file = pwd + '/../lib/background_service.rb'
Daemons.run_proc(
'background_service', # name of daemon
# :dir_mode => :normal
# :dir => File.join(pwd, 'tmp/pids'), # directory where pid file will be stored
# :backtrace => true,
# :monitor => true,
:log_output => true
) do
exec "ruby #{file}"
end
它應該是從執行在系統啓動一個shell腳本執行。
#!/bin/bash
2 HOME=/opt/halogen/ui
3
4 ruby $HOME/daemon.rb start > log
當我手動執行這個shellscript像./test.sh
它工作正常。 ruby守護進程執行。但是,按照我的要求,它應該在系統啓動時調用。當系統調用test.sh文件時,它不起作用,並且ruby守護進程也不會執行。
請幫我解決這個問題。
你怎麼知道shell腳本實際上是在啓動時執行的? –
@JustinWood:因爲該腳本還包含其他操作,並且在根用戶下以系統引導 – Jaydipsinh