Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify daemon's log and pid directories?

Tags:

ruby

daemons

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.

like image 614
jsharpe Avatar asked Oct 27 '22 01:10

jsharpe


1 Answers

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.

like image 176
DigitalRoss Avatar answered Dec 31 '22 13:12

DigitalRoss