/var/run/dsmcad.pid does not contain correct pid# after /etc/init.d/dsmcad start, making the service dsmcad appear to be crashed. Reproducible: Always Steps to Reproduce: 1. /etc/tivoli/dsm.sys: SErvername server_a COMMMethod TCPip TCPPort 1500 TCPServeraddress <address> PasswordAccess generate NodeName source ErrorLogName "/var/log/tsm/dsmerror.log" SchedLogName "/var/log/tsm/dsmsched.log" exclude.dir "/usr/portage" 2. /etc/init.d/dsmcad start Actual Results: # /etc/init.d/dsmcad status * status: crashed Expected Results: # /etc/init.d/dsmcad status * status: started After starting the service: # pgrep dsmcad 8968 # cat /run/dsmcad.pid 8964
Created attachment 329346 [details] New /etc/init.d/dsmcad-script Quick and dirty hack which just uses pgrep to find the right PID after 5 seconds. This can be a step in replacement for /usr/portage/app-backup/tsm/files/dsmcad.init.d
Please provide a diff (`diff -u oldFile newFile`) so it's easier to see what you have changed, thanks.
Comment on attachment 329346 [details] New /etc/init.d/dsmcad-script --- files/dsmcad.init.d 2012-05-16 18:52:36.000000000 +0200 +++ - 2012-11-12 20:20:25.756514763 +0100 @@ -3,6 +3,8 @@ # Distributed under the terms of the GNU General Public License v2 # $Header: /var/cvsroot/gentoo-x86/app-backup/tsm/files/dsmcad.init.d,v 1.2 2012/05/14 16:12:10 pacho Exp $ +pidfile=/var/run/dsmcad.pid + depend() { use net after dns dsmc @@ -11,8 +13,12 @@ start() { ebegin "Starting dsmcad" start-stop-daemon --start --background --nicelevel 15 \ - --make-pidfile --pidfile /var/run/dsmcad.pid \ + --make-pidfile --pidfile ${pidfile} \ --exec /opt/tivoli/tsm/client/ba/bin/dsmcad + + sleep 5 + pgrep -f /opt/tivoli/tsm/client/ba/bin/dsmcad > ${pidfile} & + eend $? }
Created attachment 329380 [details] New /etc/init.d/dsmcad script Ah, thanks for adding the patch. Noticed I forgot to do the ${pidfile} exchange inside stop(), so I redid it.
Created attachment 329446 [details, diff] Identify the process by name alone It's a bit ugly that dsmcad does background without writing the child pid to a f file, but I've found no way to disable this behaviour. This leaves us with two options: A) Identify the process by name alone B) Use the name to find the pid immediately after the process was started B has some chances of keeping track of the correct process even if more than one instance are running. But it also has some chances of getting the wrong one from time to time if two instances are started at the same time. A is simpler and should suffice for almost all realistic usage scenarios. I'll attach patches for both, but am in favour of A due to its simplicity. In any case, the --make-pidfile, --pidfile and --background arguments to start-stop-daemon must be removed. If the program does backrgound itself, there is no gain and much harm in s-s-d doing the same.
Created attachment 329448 [details, diff] Use pgrep to save the pid This patch does implement option B. It is an improved version of what Mads submitted earlier. Once --background is gone from the s-s-d options, there is no need to sleep and wait for the final daemon process to start up. The parent will only exit after the child has been created, so once s-s-d returns, the child will already be running. No point in backgrounding the pgrep either, as far as I can see. I added -x to pgrep to force an exact match, and -n to only ever return a single pid, namely that of the most recently started process. Without this latter option, there is no benefit in saving the pid, as the script still won't support more than one dsmcad process. But with this option, chances are good that the pid written to the file actually belongs to the process started by the script, so we can actually handle multiple versions of dsmcad running at the same time. Note that this attachment here is only for the sake of completeness, I still prefer the approach attached in comment #5.
Tested out your A-variant, works fine :) If you want to support multi dsmcad an idea might be to use pgrep with the -x argument, and testing that against "${command} ${dsmcad-opts}", given multiple conf.d/init.d-files and different dsmcad options. But I don't know if you ever need that...
@Pacho, please commit attachment 329446 [details, diff] as my proxy maintainer, with a revision bump as this is about runtime behaviour.
+*tsm-6.2.2.0-r2 (16 Dec 2012) +*tsm-6.4.0.0 (16 Dec 2012) +*tsm-6.3.0.5-r2 (16 Dec 2012) + + 16 Dec 2012; Pacho Ramos <pacho@gentoo.org> +files/dsmcad.init.d-r1, + +tsm-6.2.2.0-r2.ebuild, +tsm-6.3.0.5-r2.ebuild, +tsm-6.4.0.0.ebuild, + -tsm-6.2.2.0-r1.ebuild, -tsm-6.3.0.0-r1.ebuild, -tsm-6.3.0.5-r1.ebuild: + Version bump (#446896 by Chris Shelton), also fix licenses (#444412 by Ulrich + Müller) and fix init.d script (#442878 by Mads). Thanks to Martin von Gagern + for the work. Drop old. +