Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

12465 : manage the pid file using the service functions. #963

Merged
merged 2 commits into from Jul 24, 2012
Merged

12465 : manage the pid file using the service functions. #963

merged 2 commits into from Jul 24, 2012

Conversation

vrthra
Copy link
Contributor

@vrthra vrthra commented Jul 24, 2012

No description provided.

pidfile=${PIDFILE-/var/run/puppet/agent.pid}
puppetd=${PUPPETD-/usr/bin/puppet}
pidfile=${PIDFILE-/var/run/puppet.pid}
puppetd=${PUPPETD-/usr/sbin/puppetd}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is puppetd a typo? We should either stop using the puppetd executable or we should use it as the exclusive way to start the agent. Having two executables is a burden to maintain.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

puppetd worked on 2.7, but isn't even present in 3.x, so this will fail hard.

It should be /usr/bin/puppet instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

puppetd is a typo, caused by merge of 2.7 into 3.x, I will change it and update.

@HAIL9000 HAIL9000 merged commit 134f7cb into puppetlabs:3.x Jul 24, 2012
@@ -41,11 +40,9 @@ fi

start() {
echo -n $"Starting puppet agent: "
daemon $daemonopts $puppetd ${PUPPET_OPTS} ${PUPPET_EXTRA_OPTS}
daemon $daemonopts "nohup $puppetd ${PUPPET_OPTS} ${PUPPET_EXTRA_OPTS} --no-daemonize >/dev/null 2>&1 & echo \$! > $pidfile"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why nohup? This is a smell that Puppet isn't behaving properly.

Also, this appears to start a daemon process using the --no-daemonize option, which is surprising.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are asking the puppet to not fork and go to the back ground so that the initscript library is able to manage the daemonizing. This is done so that the init script can control the lifetime using a separate pidfile, and hence distinguish it from a command line invocation. This is also the reason for nohup.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nohup worked sanely in the previous pull against 2.7 (and was there to ensure that if someone has changed some environment defaults it would still work) but no longer seems to now. Same is true with the --no-daemonize flag. Not sure if puppetd had some different defaults, but when using /usr/bin/puppet we also need to add the agent face to the call in 3.x.

So this line should probably be daemon $daemonopts $puppetd ${PUPPET_OPTS} ${PUPPET_EXTRA_OPTS}, as long as ${PUPPET_OPTS} includes agent and --daemonize.

Then RETVAL=$? to capture the success.

Then I would use pgrep -f '$puppetd ${PUPPET_OPTS} ${PUPPET_EXTRA_OPTS}' to get the pid # and write it to the pidfile (as daemon doesn't seem to actually write the pidfile out).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added --no-daemonize as separate from PUPPET_OPTS as it is used elsewhere in genconfig. Even though daemon works due to a quirk of bash, which disables SIGHUP, I felt that it was not safe to rely on it see so.q. I also felt that directly capturing the pid file after execution was less brittle than relying on pgrep (since pgrep relies on a pattern to match the pid).

@HAIL9000
Copy link
Contributor

Sorry @jeffmccune... you started commenting at the exact same time I merged this. It sounds like you have some valid concerns, so I can make sure these changes get in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants