supervision - discussion about system services, daemon supervision, init, runlevel management, and tools such as s6 and runit
 help / color / mirror / Atom feed
* post action
@ 2010-11-05 11:36 Alejandro Mery
  2010-11-05 12:11 ` Charlie Brady
  2010-11-06 12:25 ` Laurent Bercot
  0 siblings, 2 replies; 6+ messages in thread
From: Alejandro Mery @ 2010-11-05 11:36 UTC (permalink / raw)
  To: supervision

Hi, I have a problem with a service [1] which runs fine and handles 
HUP, TERM correctly and sends output to stderr as a good citizen. 
Unfortunately it (re)creates a unix socket with permissions unfit 
for the purpose, so I have to chmod g+w /var/run/thin-*/socket every 
time. cron gives me a granularity of 1 minute which still makes the 
application unreachable for up-to one looooong minute.

The authors don't care because it works fine when daemonizing... and 
"one shall daemonize the daemons"... no comment on that.

Is there an elegant way of solving this issue with runit?

Thanks,
Alejandro Mery

[1] <http://code.macournoyer.com/thin/>


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

* Re: post action
  2010-11-05 11:36 post action Alejandro Mery
@ 2010-11-05 12:11 ` Charlie Brady
  2010-11-05 12:15   ` Charlie Brady
  2010-11-05 13:11   ` Alejandro Mery
  2010-11-06 12:25 ` Laurent Bercot
  1 sibling, 2 replies; 6+ messages in thread
From: Charlie Brady @ 2010-11-05 12:11 UTC (permalink / raw)
  To: Alejandro Mery; +Cc: supervision


On Fri, 5 Nov 2010, Alejandro Mery wrote:

> Hi, I have a problem with a service [1] which runs fine and handles HUP, TERM
> correctly and sends output to stderr as a good citizen. Unfortunately it
> (re)creates a unix socket with permissions unfit for the purpose, so I have to
> chmod g+w /var/run/thin-*/socket every time. cron gives me a granularity of 1
> minute which still makes the application unreachable for up-to one looooong
> minute.
> 
> The authors don't care because it works fine when daemonizing... and "one
> shall daemonize the daemons"... no comment on that.
> 
> Is there an elegant way of solving this issue with runit?

I don't think it's runit's problem. It's a problem with thin. Since thin
appears to be a daemon written in ruby, you can just patch it.

If it were a binary only application, that you couldn't patch, you could 
use LD_LIBRARY_PRELOAD to load a shim which captures the chmod call, and 
just ignores it if the path matches your socket.

> Thanks,
> Alejandro Mery
> 
> [1] <http://code.macournoyer.com/thin/>
> 
> 


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

* Re: post action
  2010-11-05 12:11 ` Charlie Brady
@ 2010-11-05 12:15   ` Charlie Brady
  2010-11-05 13:11   ` Alejandro Mery
  1 sibling, 0 replies; 6+ messages in thread
From: Charlie Brady @ 2010-11-05 12:15 UTC (permalink / raw)
  To: Alejandro Mery; +Cc: supervision


Alternatively, your run script could fork. The parent could exec thin. 
The child could wait until thin makes the bad socket, then fix it, then 
exit. This would leave you with a zombie, but a good socket.


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

* Re: post action
  2010-11-05 12:11 ` Charlie Brady
  2010-11-05 12:15   ` Charlie Brady
@ 2010-11-05 13:11   ` Alejandro Mery
  2010-11-05 13:19     ` Charlie Brady
  1 sibling, 1 reply; 6+ messages in thread
From: Alejandro Mery @ 2010-11-05 13:11 UTC (permalink / raw)
  To: Charlie Brady; +Cc: supervision

Hi Charlie,

El 05/11/10 13:11, Charlie Brady escribió:
> On Fri, 5 Nov 2010, Alejandro Mery wrote:
>
>> Hi, I have a problem with a service [1] which runs fine and handles HUP, TERM
>> correctly and sends output to stderr as a good citizen. Unfortunately it
>> (re)creates a unix socket with permissions unfit for the purpose, so I have to
>> chmod g+w /var/run/thin-*/socket every time. cron gives me a granularity of 1
>> minute which still makes the application unreachable for up-to one looooong
>> minute.
>>
>> The authors don't care because it works fine when daemonizing... and "one
>> shall daemonize the daemons"... no comment on that.
>>
>> Is there an elegant way of solving this issue with runit?
> I don't think it's runit's problem. It's a problem with thin. Since thin
> appears to be a daemon written in ruby, you can just patch it.

yes, I agree it's not runit's problem, it's thin's problem. And 
patching leads to maintenance problems. So I was wondering if anyone 
had solved the "problem" of post actions using service/control/<c> 
or similar.

> If it were a binary only application, that you couldn't patch, you could
> use LD_LIBRARY_PRELOAD to load a shim which captures the chmod call, and
> just ignores it if the path matches your socket.

that's not a bad idea

Regards,
Alejandro Mery


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

* Re: post action
  2010-11-05 13:11   ` Alejandro Mery
@ 2010-11-05 13:19     ` Charlie Brady
  0 siblings, 0 replies; 6+ messages in thread
From: Charlie Brady @ 2010-11-05 13:19 UTC (permalink / raw)
  To: Alejandro Mery; +Cc: supervision


On Fri, 5 Nov 2010, Alejandro Mery wrote:

> > If it were a binary only application, that you couldn't patch, you could
> > use LD_LIBRARY_PRELOAD to load a shim which captures the chmod call, and
> > just ignores it if the path matches your socket.
> 
> that's not a bad idea

I used that method once with an unpatched qmail (before DJB allowed 
distribution of patched versions) to prevent it forwarding to 0.0.0.0. I 
could dig up the code if that would be helpful to you.


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

* Re: post action
  2010-11-05 11:36 post action Alejandro Mery
  2010-11-05 12:11 ` Charlie Brady
@ 2010-11-06 12:25 ` Laurent Bercot
  1 sibling, 0 replies; 6+ messages in thread
From: Laurent Bercot @ 2010-11-06 12:25 UTC (permalink / raw)
  To: supervision

> Unfortunately it (re)creates a unix socket with permissions unfit 
> for the purpose, so I have to chmod g+w /var/run/thin-*/socket every 
> time. cron gives me a granularity of 1 minute which still makes the 
> application unreachable for up-to one looooong minute.

 If you want to avoid patching software or doing ugly things like
intercepting syscalls (YMMV, but to me it IS ugly :P), depending on
your OS, you could set up an additional service that watches the
socket creation and automatically chmods it to the right permissions.

 Unfortunately, Unix does not offer any portable way to be notified
of FS operations, so the code of that additional service would have to
be OS-specific. For instance, you'd use "inotify" on Linux and "kevent"
on BSD.

 Or you would have to resort to polling - which is exactly what cron does
anyway, except using a specific service would let you have control over
the polling granularity. But I am definitely not going to suggest that.
(What is the lesser evil between polling and intercepting syscalls? now
that's an interesting question of faith. :))

-- 
 Laurent


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

end of thread, other threads:[~2010-11-06 12:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-05 11:36 post action Alejandro Mery
2010-11-05 12:11 ` Charlie Brady
2010-11-05 12:15   ` Charlie Brady
2010-11-05 13:11   ` Alejandro Mery
2010-11-05 13:19     ` Charlie Brady
2010-11-06 12:25 ` 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).