supervision - discussion about system services, daemon supervision, init, runlevel management, and tools such as s6 and runit
 help / color / mirror / Atom feed
* redirection tricks on processor invocation
@ 2009-06-02 10:48 Joan Picanyol i Puig
  2009-06-03  6:26 ` Laurent Bercot
  0 siblings, 1 reply; 6+ messages in thread
From: Joan Picanyol i Puig @ 2009-06-02 10:48 UTC (permalink / raw)
  To: supervision

Dear all,

I have an application that generates aggregate reports from separate
log streams. In order to avoid loosing data, it should be invoked as a
processor from all of it's sources log directories. The application
reads from stdin (and thus know what stream it is called from and what
other streams should look at). However, I don't the resultant log file
to be altered (since I must archive it for auditing purposes).

I've been struggling to find the correct fd copying and redirections so
that whenever runit feeds @*.u to my processor a copy of it is sent to
stdout (the application writes to a separate location), but to no avail. 

In summary, I want a copy of my processor's stdin to be seen by svlogd
as my processor's stdout. Any ideas?

tks
-- 
pica


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: redirection tricks on processor invocation
  2009-06-02 10:48 redirection tricks on processor invocation Joan Picanyol i Puig
@ 2009-06-03  6:26 ` Laurent Bercot
  2009-06-03 10:31   ` Joan Picanyol i Puig
  0 siblings, 1 reply; 6+ messages in thread
From: Laurent Bercot @ 2009-06-03  6:26 UTC (permalink / raw)
  To: supervision

> In summary, I want a copy of my processor's stdin to be seen by svlogd
> as my processor's stdout. Any ideas?

 Use multitee: http://code.dogmap.org/fdtools/multitee/

 Your processor could be, for instance, if you have execline installed:
 exec execlineb -c "
  piperw 6 7
  background { fdclose 7 fdmove 0 6 yourapplication }
  fdclose 6
  multitee 0-1,7
 "

 which copies stdin to stdout untouched, but also feeds a copy of
stdin to yourapplication's stdin.

-- 
 Laurent


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: redirection tricks on processor invocation
  2009-06-03  6:26 ` Laurent Bercot
@ 2009-06-03 10:31   ` Joan Picanyol i Puig
  2009-06-03 10:38     ` Joan Picanyol i Puig
  0 siblings, 1 reply; 6+ messages in thread
From: Joan Picanyol i Puig @ 2009-06-03 10:31 UTC (permalink / raw)
  To: supervision

* Laurent Bercot <ska-supervision@skarnet.org> [20090603 08:27]:
> > In summary, I want a copy of my processor's stdin to be seen by svlogd
> > as my processor's stdout. Any ideas?
> 
>  Use multitee: http://code.dogmap.org/fdtools/multitee/
> 
>  Your processor could be, for instance, if you have execline installed:
>  exec execlineb -c "
>   piperw 6 7
>   background { fdclose 7 fdmove 0 6 yourapplication }
>   fdclose 6
>   multitee 0-1,7
>  "
> 
>  which copies stdin to stdout untouched, but also feeds a copy of
> stdin to yourapplication's stdin.

That's exactly what I want. Given that piperw apparently has no shell
equivalent without a named pipe I guess it's time for me to bite the
bullet and just use skalibs.

tks
--
pica


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: redirection tricks on processor invocation
  2009-06-03 10:31   ` Joan Picanyol i Puig
@ 2009-06-03 10:38     ` Joan Picanyol i Puig
  2009-06-12 11:48       ` Joan Picanyol i Puig
  0 siblings, 1 reply; 6+ messages in thread
From: Joan Picanyol i Puig @ 2009-06-03 10:38 UTC (permalink / raw)
  To: supervision

* Joan Picanyol i Puig <lists-supervision@biaix.org> [20090603 12:31]:
> * Laurent Bercot <ska-supervision@skarnet.org> [20090603 08:27]:
> > > In summary, I want a copy of my processor's stdin to be seen by svlogd
> > > as my processor's stdout. Any ideas?
> > 
> >  Use multitee: http://code.dogmap.org/fdtools/multitee/
> > 
> >  Your processor could be, for instance, if you have execline installed:
> >  exec execlineb -c "
> >   piperw 6 7
> >   background { fdclose 7 fdmove 0 6 yourapplication }
> >   fdclose 6
> >   multitee 0-1,7
> >  "
> > 
> >  which copies stdin to stdout untouched, but also feeds a copy of
> > stdin to yourapplication's stdin.
> 
> Given that piperw apparently has no shell equivalent without a named
> pipe I guess it's time for me to bite the bullet and just use skalibs.

Actually, it's multitee's dependency in skalibs that makes me bite the
bullet (I should be able to avoid named pipes using subshells in my
processor's script.

qvb
--
pica


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: redirection tricks on processor invocation
  2009-06-03 10:38     ` Joan Picanyol i Puig
@ 2009-06-12 11:48       ` Joan Picanyol i Puig
  2009-06-13  5:13         ` Laurent Bercot
  0 siblings, 1 reply; 6+ messages in thread
From: Joan Picanyol i Puig @ 2009-06-12 11:48 UTC (permalink / raw)
  To: supervision

* Joan Picanyol i Puig <lists-supervision@biaix.org> [20090603 12:38]:
> * Joan Picanyol i Puig <lists-supervision@biaix.org> [20090603 12:31]:
> > * Laurent Bercot <ska-supervision@skarnet.org> [20090603 08:27]:
> > > > In summary, I want a copy of my processor's stdin to be seen by svlogd
> > > > as my processor's stdout. Any ideas?
> > > 
> > >  Use multitee: http://code.dogmap.org/fdtools/multitee/
> > > 
> > >  Your processor could be, for instance, if you have execline installed:
> > >  exec execlineb -c "
> > >   piperw 6 7
> > >   background { fdclose 7 fdmove 0 6 yourapplication }
> > >   fdclose 6
> > >   multitee 0-1,7
> > >  "
> > > 
> > >  which copies stdin to stdout untouched, but also feeds a copy of
> > > stdin to yourapplication's stdin.
> > 
> > Given that piperw apparently has no shell equivalent without a named
> > pipe
> 
> I should be able to avoid named pipes using subshells in my
> processor's script.

A week later, I've been unable to translate this simple execline snippet
to shell syntax. I can't figure out a way to workaround the fact that
shell pipes are created before redirection. Any hints?

tks
--
pica


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: redirection tricks on processor invocation
  2009-06-12 11:48       ` Joan Picanyol i Puig
@ 2009-06-13  5:13         ` Laurent Bercot
  0 siblings, 0 replies; 6+ messages in thread
From: Laurent Bercot @ 2009-06-13  5:13 UTC (permalink / raw)
  To: supervision

> A week later, I've been unable to translate this simple execline snippet
> to shell syntax. I can't figure out a way to workaround the fact that
> shell pipes are created before redirection. Any hints?

 Your problem is that the shell can't open anonymous fds. The only way
to get an anonymous pipe is the | construct, which does not open more fds
because it's redirected at once to 1 and 0.
 The multitee command needs one more fd to be opened, and you can't do
that with anonymous pipes. You need a named pipe for this:

 mkfifo /tmp/fifo ;
 yourapplication </tmp/fifo &
 exec 7>/tmp/fifo multitee 0-1,7

 Inelegant? Unsatisfying?
 Go forth, o my convert, and preach the virtues of execline. :)

-- 
 Laurent


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-06-13  5:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-02 10:48 redirection tricks on processor invocation Joan Picanyol i Puig
2009-06-03  6:26 ` Laurent Bercot
2009-06-03 10:31   ` Joan Picanyol i Puig
2009-06-03 10:38     ` Joan Picanyol i Puig
2009-06-12 11:48       ` Joan Picanyol i Puig
2009-06-13  5:13         ` Laurent Bercot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).