Skip to content

Instantly share code, notes, and snippets.

@mrflip
Forked from ashb/run-chef.sh
Created October 30, 2011 18:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrflip/1326206 to your computer and use it in GitHub Desktop.
Save mrflip/1326206 to your computer and use it in GitHub Desktop.
Make the chef-client (v0.10+) daemon process wake and run, and print what its doing to stdout
#!/bin/bash
#
# Author:: Ash Berlin (ash_github@firemirror.om)
# Copyright:: Copyright (c) 2011 DigiResults Ltd.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Typically /var/run/chef/client.pid (init.d) or /etc/sv/chef-client/supervise/pid (runit)
pid_file="/var/run/chef/client.pid"
log_file="/var/log/chef/client.log"
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 "$log_file" > $pipe &
tail_pid=$!
sudo kill -USR1 $(cat "$pid_file")
sed -r '/(ERROR: Sleeping for [[:digit:]+] seconds before trying again|INFO: Report handlers complete)$/{q}' $pipe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment