Gentoo Archives: gentoo-dev

From: Max Arnold <lwarxx@×××××.com>
To: gentoo-dev@l.g.o
Subject: [gentoo-dev] start-stop-daemon and python-wrapper
Date: Tue, 15 Dec 2009 10:05:58
Message-Id: 20091215085453.GA7941@bbone
1 Hello all.
2
3 I've got something similar to this: http://archives.gentoo.org/gentoo-dev/msg_54ec9c3d4c15c3f52e4c71fef5d42633.xml
4 I have custom python script which should run in background. It spawns several threads but does
5 not daemonizes itself, so I use following init.d script ($MYSCRIPT writes its own pid upon
6 startup and removes it when stopped, also it refuses to start if pid already exists):
7
8 start () {
9 /sbin/start-stop-daemon --start --pidfile $MYSCRIPT_PID \
10 --chdir $MYSCRIPT_HOME --background --exec $MYSCRIPT --startas $MYSCRIPT
11 eend $?
12 }
13
14 stop () {
15 /sbin/start-stop-daemon --stop --pidfile $MYSCRIPT_PID --signal INT
16 result=$?
17 rm -f $MYSCRIPT_PID
18 eend $result
19 }
20
21 Now I noticed it does not work reliably, because shutdown takes some time and start-stop-daemon
22 does not wait for this. I started to experiment with --exec and other options and now can't find
23 correct way to handle process name, because it starts with /usr/bin/python2.6 and I don't want
24 to hardcode it in ebuild or init script. Also I do not want to introduce fixed delay because
25 actual shutdown time varies a lot.
26
27 Initially my script has "/usr/bin/env python" shebang line. When I checked actual installed
28 file, it contained "/usr/bin/python2.6". Who is responsible for this modification (eclass,
29 distutils or something else)? Why not "/usr/bin/env python2.6"? How this relates to python-
30 wrapper linked to /usr/bin/python and what it is supposed to do? Is /usr/bin/python2.6 a real
31 python binary or another wrapper? What is the recommended way to write ebuilds and init scripts
32 in such cases? Any documentation or examples? I've found several discussions on bugzilla but
33 still can't get the whole picture about this python wrapper thing and recommended ways to use.
34
35 My custom ebuild inherits eutils/distutils and contains >=dev-lang/python-2.5 in DEPEND.
36
37 Thanks!

Replies

Subject Author
Re: [gentoo-dev] start-stop-daemon and python-wrapper Brian Harring <ferringb@×××××.com>