I am booting using a machine using chef. I need it to install a init.d script which it does and when the script is invoked at the end of chef run the script fails on the require 'daemons' line (shown below). I have a print before and after the require and the one before the require is logged.
# my_invoked_script.rb
$stdout.reopen("output.txt")
$stderr.reopen("err.txt")
pid = fork
if pid.nil?
puts "Before"
require 'daemons'
puts "After"
...
else
Process.detach(pid)
end
The before print is logged. The after print is not. I am thinking since this is at boot time some env variables may not be set right. Has anyone been able to run ruby scripts with a require in them at boot time?
My init.d script is a standard script with start function as follows:
start(){
/usr/local/bin/ruby /home/ubuntu/my_invoked_script.rb
}
Logging into terminal and running the script shows no error and things proceed as normal.
Ruby 1.9.2 ubuntu 11.04 though I am not sure either of them are the issue here.