Getting feedback from waking chef-client daemon


#1

So I recently upgrade from chef 0.9 to 0.10 and remembered that you can now send the client daemon on USR1 to wake it up and make it do a run.

Yippie.

Except that you get no output that it’s doing anything: less wonderful.

So I made a short script that will send a signal then write the output from the log and stop when the run completes:

https://gist.github.com/1325982

(Included in-band at end of email for everyone to lazy to click.)

Basically its like doing tail -f $log_file, but it automatically stops when the chef run does.

-ash

END

#!/bin/bash
set -e

declare tail_pid

on_exit() {
rm -f $pipe
[ -n “$tail_pid” ] && kill $tail_pid
}

trap “on_exit” EXIT ERR

pipe=/tmp/pipe-$$
mkfifo $pipe

tail -fn0 /var/log/chef/client.log > $pipe &

tail_pid=$!

sudo kill -USR1 (cat /var/run/chef/client.pid) sed -r '/(ERROR: Sleeping for [[:digit:]+] seconds before trying again|INFO: Report handlers complete)/{q}’ $pipe


#2

Clever! Thanks for sharing.

Adam


Opscode, Inc.
Adam Jacob, Chief Product Officer
T: (206) 619-7151 E: adam@opscode.com

On Oct 30, 2011, at 10:46 AM, Ash Berlin wrote:

So I recently upgrade from chef 0.9 to 0.10 and remembered that you can now send the client daemon on USR1 to wake it up and make it do a run.

Yippie.

Except that you get no output that it’s doing anything: less wonderful.

So I made a short script that will send a signal then write the output from the log and stop when the run completes:

https://gist.github.com/1325982

(Included in-band at end of email for everyone to lazy to click.)

Basically its like doing tail -f $log_file, but it automatically stops when the chef run does.

-ash

END

#!/bin/bash
set -e

declare tail_pid

on_exit() {
rm -f $pipe
[ -n “$tail_pid” ] && kill $tail_pid
}

trap “on_exit” EXIT ERR

pipe=/tmp/pipe-$$
mkfifo $pipe

tail -fn0 /var/log/chef/client.log > $pipe &

tail_pid=$!

sudo kill -USR1 (cat /var/run/chef/client.pid) sed -r '/(ERROR: Sleeping for [[:digit:]+] seconds before trying again|INFO: Report handlers complete)/{q}’ $pipe