FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Gentoo > Gentoo Development

 
 
LinkBack Thread Tools
 
Old 12-15-2009, 07:54 AM
Max Arnold
 
Default start-stop-daemon and python-wrapper

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!
 
Old 12-18-2009, 07:16 PM
Brian Harring
 
Default start-stop-daemon and python-wrapper

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
 
Old 12-18-2009, 09:01 PM
James Rowe
 
Default start-stop-daemon and python-wrapper

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
 

Thread Tools




All times are GMT. The time now is 03:10 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org