public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] start-stop-daemon and python-wrapper
@ 2009-12-15  8:54 Max Arnold
  2009-12-18 20:16 ` Brian Harring
  0 siblings, 1 reply; 3+ messages in thread
From: Max Arnold @ 2009-12-15  8:54 UTC (permalink / raw
  To: gentoo-dev

Hello all.

I've got something similar to this: http://archives.gentoo.org/gentoo-dev/msg_54ec9c3d4c15c3f52e4c71fef5d42633.xml
I have custom python script which should run in background. It spawns several threads but does
not daemonizes itself, so I use following init.d script ($MYSCRIPT writes its own pid upon
startup and removes it when stopped, also it refuses to start if pid already exists):

start () {
	/sbin/start-stop-daemon --start --pidfile $MYSCRIPT_PID \
		--chdir $MYSCRIPT_HOME --background --exec $MYSCRIPT --startas $MYSCRIPT
	eend $?
}

stop () {
	/sbin/start-stop-daemon --stop --pidfile $MYSCRIPT_PID --signal INT
	result=$?
	rm -f $MYSCRIPT_PID
	eend $result
}

Now I noticed it does not work reliably, because shutdown takes some time and start-stop-daemon
does not wait for this. I started to experiment with --exec and other options and now can't find
correct way to handle process name, because it starts with /usr/bin/python2.6 and I don't want
to hardcode it in ebuild or init script. Also I do not want to introduce fixed delay because
actual shutdown time varies a lot.

Initially my script has "/usr/bin/env python" shebang line.  When I checked actual installed
file, it contained "/usr/bin/python2.6".  Who is responsible for this modification (eclass,
distutils or something else)?  Why not "/usr/bin/env python2.6"?  How this relates to python-
wrapper linked to /usr/bin/python and what it is supposed to do?  Is /usr/bin/python2.6 a real
python binary or another wrapper? What is the recommended way to write ebuilds and init scripts
in such cases?  Any documentation or examples?  I've found several discussions on bugzilla but
still can't get the whole picture about this python wrapper thing and recommended ways to use.

My custom ebuild inherits eutils/distutils and contains >=dev-lang/python-2.5 in DEPEND.

Thanks!



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

* Re: [gentoo-dev] start-stop-daemon and python-wrapper
  2009-12-15  8:54 [gentoo-dev] start-stop-daemon and python-wrapper Max Arnold
@ 2009-12-18 20:16 ` Brian Harring
  2009-12-18 22:01   ` James Rowe
  0 siblings, 1 reply; 3+ messages in thread
From: Brian Harring @ 2009-12-18 20:16 UTC (permalink / raw
  To: gentoo-dev; +Cc: Max Arnold

[-- Attachment #1: Type: text/plain, Size: 393 bytes --]

On Tue, Dec 15, 2009 at 03:54:53PM +0700, Max Arnold wrote:
> Initially my script has "/usr/bin/env python" shebang line.  When I checked actual installed
> file, it contained "/usr/bin/python2.6".  Who is responsible for this modification (eclass,
> distutils or something else)?  Why not "/usr/bin/env python2.6"?

distutils.  If you find a knob to disable that, I'd be interested...
~brian

[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [gentoo-dev] start-stop-daemon and python-wrapper
  2009-12-18 20:16 ` Brian Harring
@ 2009-12-18 22:01   ` James Rowe
  0 siblings, 0 replies; 3+ messages in thread
From: James Rowe @ 2009-12-18 22:01 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 839 bytes --]

Excerpts from Brian Harring's message of Fri Dec 18 20:16:19 +0000 2009:
> On Tue, Dec 15, 2009 at 03:54:53PM +0700, Max Arnold wrote:
> > Initially my script has "/usr/bin/env python" shebang line.  When I checked actual installed
> > file, it contained "/usr/bin/python2.6".  Who is responsible for this modification (eclass,
> > distutils or something else)?  Why not "/usr/bin/env python2.6"?
> 
> distutils.  If you find a knob to disable that, I'd be interested...
> ~brian

  There isn't a trigger to change this behaviour [currently].

  You can monkey patch it quite easily though, if you're willing.  Something
like the following pasted in to the setup.py does the trick.

    import re
    from distutils.command import build_scripts
    build_scripts.first_line_re = re.compile("^never gonna match you up$")
-- 
Thanks,

James

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

end of thread, other threads:[~2009-12-18 22:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-15  8:54 [gentoo-dev] start-stop-daemon and python-wrapper Max Arnold
2009-12-18 20:16 ` Brian Harring
2009-12-18 22:01   ` James Rowe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox