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!