Using Daemons, how do I specify that my script's log goes in /log/ and its pid goes in /tmp/pids/?
I've read the docs, and I see :dir/:dir_mode, but I can only make it do one or the other, not both -- seems like a really bad set of options if you ask me.
It doesn't look like vanilla Daemons
can do what you want, but it's fixable. Try something like this:
require 'rubygems'
require 'daemons'
module Daemons
class Application
def logfile; '/log/f1'; end
def output_logfile; '/log/f2'; end
end
end
Daemons.run '/tmp/test.rb',
:dir => '/tmp/pids',
:dir_mode => :normal,
:ontop => false,
:log_output => true
You probably want the logic of *logfile to act more like the originals; just scan the daemons source for def.logfile. I would also have rather patched a subclass of Application
but it is instantiated by name elsewhere in module Daemons so that makes things tricky.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With