Puppet init script doesn't create the pid file?

5.5k views Asked by At
  • CentOS release 5.4 (Final)
  • puppet-server-2.7.19-1.el5 is installed from the puppetlabs repo.

puppetmaster is started successfull, but it doesn't create the pid file. It is the reason for [ FAILED ] message when stopping:

/etc/init.d/puppetmaster stop
Stopping puppetmaster:                                     [FAILED]

The init script: http://fpaste.org/nsfI/

The /etc/rc.d/init.d/functions library: http://fpaste.org/ox5Q/

And this is what I get when running in the debug mode: http://fpaste.org/DkoS/

I know the way to echo the pid to a file manually after starting, but why doesn't daemon function's --pidfile work?

daemon $PUPPETMASTER $PUPPETMASTER_OPTS --masterport=${PUPPETMASTER_PORTS[$i]} --pidfile=/var/run/puppet/puppetmaster.${PUPPETMASTER_PORTS[$i]}.pid

Sure, Puppet master is running as puppet user:

ps -ef | grep [p]uppet
puppet   23418     1  0 18:13 ?        00:00:00 /usr/bin/ruby /usr/sbin/puppetmasterd

and the owner of /var/run/puppet/ folder is puppet:

# ls -ld /var/run/puppet/
drwxr-xr-x 2 puppet puppet 4096 Sep 17 18:46 /var/run/puppet/
2

There are 2 answers

0
eikonomega On

So, it looks to me like there could be a couple of possibilities here:

  1. If you are trying to use the --pidfile option of the daemon command I believe you have a syntax problem.

    • Red Hat's daemon command has the following (unhelpful) signature: Usage: daemon [+/-nicelevel] {program}. What isn't altogether clear is that anything that you include after the program location is treated as an option passed to the program, not to the daemon function call.
    • So, in your case you are passing the --pidfile argument to $PUPPETMASTER itself as opposed to daemon(). You could remedy this by using the following: daemon --pidfile=/var/run/puppet/puppetmaster.${PUPPETMASTER_PORTS[$i]}.pid $PUPPETMASTER $PUPPETMASTER_OPTS --masterport=${PUPPETMASTER_PORTS[$i]}
  2. The second option here is that $PUPPETMASTER (or rather, the program behind it) might daemonize itself, and if so, could be responsible for creating its own .pid file. The process management tool Circus works in this way. It's probably an option in a configuration file or for the program representing by $PUPPETMASTER.

    • I'm not a Puppet user, so I won't be able to help you with the specifics here. But I would look into the Puppet labs documentation to find out more about this option.
    • It is important to note if $PUPPETMASTER is daemonizing itself, then the --pidfile argument being passed to daemon() will have no effect.

Good hunting!

0
vladr On

It is up to the controlled program (in this case puppetmasterd), not the daemon() function, to create the pidfile; daemon() relies on this.

Confirm where puppetmasterd creates its pidfile (it could be /var/run/puppet.pid, /var/lib/puppet/run/master.pid, etc.) To find out, inspect the contents of puppetmasterd (if a script), or kill puppetmasterd then strace -f puppetmasterd 2>&1 | grep '\.pid'.

Modify the value of pidfile in your /etc/init.d/puppetmaster accordingly.