tags:

views:

140

answers:

1

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.

A: 

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.

DigitalRoss