Re: single instance of multilog for multiple processes

Daryl Tester <[email protected]> Mon, 21 Sep 2009 09:16:12 +0930
Newsgroups gmane.comp.djb.syslog
Message-ID <[email protected]>
(* Reply to /dev/null'd *)

(* Also have severe head cold - disinfect screen after reading *)

Richard Lucassen wrote:

> I'd like to have multiple independent processes log to 1 multilog. I
> think the following solution using a fifo is a good idea:
> 
> $ cat run
> 
> #!/bin/sh
> while true; do
>   /usr/local/bin/setuidgid loguser /usr/local/bin/multilog t \
>   /var/log/multilog
> done < /usr/local/multilog/fifo

If you're using this as a run script (inferred by the "cat run")
then supervise will be sending signals to the shell, not multilog
(and then the shell with do with it what it damn well pleases,
which may include not passing it on to its child processes).

As supervise handles the reinvocation of multilog for you, a
simpler scheme might be:

#!/bin/sh

exec < /usr/local/multilog/fifo /usr/local/bin/setuidgid loguser \
	/usr/local/bin/multilog t /var/log/multilog

> Is this the right way to do this or are there some restrictions or
> disadvantages? Two processes writing simultaneously to the fifo
> will be processed sequentially AFAIK.

You could also potentially (depending on access rights etc.) do

process1 | setuidgid loguser multilog [arguments ...]
process2 | setuidgid loguser multilog [arguments ...]
etc.

i.e. not run multilog as a supervised process.  I do this with
some batch processes - multilog does its log file size and number
restriction thing, and the file system is happy ...

-- 
Regards,
  Daryl Tester

"Scheme is an exotic sports car. Fast. Manual transmission. No radio.
 Common Lisp is Howl's Moving Castle."
  -- Steve Yegge, comparing Lisp families to cars.