avoid multi chef client run starts

Change-Id: Ie676e4200f2ce4574d53021b28b6c000641645ea
Closes-Bug: 1398963
This commit is contained in:
xiaodongwang 2014-12-03 11:55:01 -08:00 committed by Xiaodong Wang
parent bc97a1b193
commit f49134271e
3 changed files with 24 additions and 6 deletions

View File

@ -24,10 +24,19 @@
cat << EOF > /etc/chef/chef_client_run.sh
#!/bin/bash
touch /tmp/chef.log
PIDFILE=/tmp/chef_client_run.pid
if [ -f \\$PIDFILE ]; then
pid=\\$(cat \\$PIDFILE)
if [ -f /proc/\\$pid/exe ]; then
echo "there are chef_client_run.sh running with pid \\$pid" &>> /tmp/chef.log
exit 1
fi
fi
echo \\$$ > \\$PIDFILE
while true; do
echo "run chef-client on \`date\`" &>> /tmp/chef.log
clients=\\$(pgrep chef-client)
if [ "\\$?" == "0" ]; then
if [[ "\\$?" == "0" ]]; then
echo "there are chef-clients '\\$clients' running" &>> /tmp/chef.log
break
else

View File

@ -1,9 +1,9 @@
#if $str($getVar('anamon_enabled','')) == "1"
#if $getVar("compass_server", "") != ""
#if $getVar("compass_server", "") != ""
wget -O /tmp/anamon "http://$compass_server:$http_port/cobbler/aux/anamon"
python /tmp/anamon --name "$name" --server "$compass_server" --port "$http_port"
#else
#else
wget -O /tmp/anamon "http://$server:$http_port/cobbler/aux/anamon"
python /tmp/anamon --name "$name" --server "$_server" --port "$http_port"
#end if
python /tmp/anamon --name "$name" --server "$server" --port "$http_port"
#end if
#end if

View File

@ -23,10 +23,19 @@
cat << EOF > /etc/chef/chef_client_run.sh
#!/bin/bash
touch /tmp/chef.log
PIDFILE=/tmp/chef_client_run.pid
if [ -f \\$PIDFILE ]; then
pid=\\$(cat \\$PIDFILE)
if [ -f /proc/\\$pid/exe ]; then
echo "there are chef_client_run.sh running with pid \\$pid" &>> /tmp/chef.log
exit 1
fi
fi
echo \\$$ > \\$PIDFILE
while true; do
echo "run chef-client on \`date\`" &>> /tmp/chef.log
clients=\\$(pgrep chef-client)
if [ "\\$?" == "0" ]; then
if [[ "\\$?" == "0" ]]; then
echo "there are chef-clients '\\$clients' running" &>> /tmp/chef.log
break
else