LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   RedHat: Daemons (https://www.linuxquestions.org/questions/linux-general-1/redhat-daemons-879564/)

BeefyElbow 05-08-2011 11:41 PM

RedHat: Daemons
 
Hi all,

I've inherited a RedHat system, and I'm trying to control some daemons using the classic start and stop mechanism.

I'm having problems understanding when and where the PID is written to the PID file. I'm not sure if the file I pass in is being used.

I've created a startup script in /etc/init.d called daemoncontrol.
Here's a snippet from the 'start' section of my daemoncontrol:

Code:

PID_FILE=/var/log/daemontest1.pid

daemon  --pidfile="$PID_FILE" '/bin/launchmgr --daemon "daemontest1 -d 127.0.0.1"'

I've got an app called 'launchmgr' that expects some parameters, one of which is my daemon application (daemontest1).

I'm expecting here that the PID of the launchmgr instance will be written to the specified PID file. This doesn't appear to be the case. Instead, the PID seems to be written to /var/run/launchmgr.pid instead, as if it's always using the base of the application. Where does this happen?

I've ploughed through /etc/init.d/functions and it's not in there.

Kernel 2.6.18-164.el5

trickykid 05-09-2011 02:13 PM

The standard for PID files is actually /var/run/

/var/log is for log files. Why not just change your app to look for the pid file in /var/run instead? Did you write the program that creates the pid in /var/run?

BeefyElbow 05-09-2011 03:17 PM

Bah! Typo!

The path is set as /var/run/!

That makes the definition of the variable:

Code:

PID_FILE=/var/run/daemontest1.pid
The only part I really don't understand is where the PID file is actually updated with the PID value. Where is that written? Is it some low-level kernel action, or in some other script somewhere. I can't find anywhere in Red Hat's daemon function (/etc/init.d/functions) that writes the PID to the file.

Using echo statements in the 'daemon' function, I can see that my specified PID_FILE is passed through correctly. However, after this section:

Code:

        # And start it up.
        if [ -z "$user" ]; then
          $nice /bin/bash -c "$corelimit >/dev/null 2>&1 ; $*"
        else
          $nice runuser -s /bin/bash - $user -c "$corelimit >/dev/null 2>&1 ; $*"
        fi

An incorrect PID File for the basename of the launcher is updated with the PID. Where does this happen?


All times are GMT -5. The time now is 01:55 AM.