Running chef-client on cmdline won't exit

hi. when i run chef-client on the cmdline, it won’t exit, it holds open
my pts. shouldn’t it exit? when the cmdline run is complete, i have to
ctrl-c to get my prompt back.

is using the “–once” switch the proper thing to do? if memory serves,
i didn’t used to have to do that. maybe that was a prior release…

on my system, chef-client is running as a daemon (using -d).

below are the details.

thanks,
kallen

client: centos 5.7, chef 0.10.4.

the process list:

[root@proxy1-dev ~]# ps wwwwaxuf | grep chef-clien[t]
root 14527 6.4 5.2 94812 91268 pts/0 S+ 00:53 0:14 | _ /usr/bin/ruby /usr/bin/chef-client
root 4205 0.5 5.1 94112 89876 ? S 00:24 0:11 /usr/bin/ruby /usr/bin/chef-client -d -c /etc/chef/client.rb -L /var/log/chef/client.log -P /var/run/chef/client.pid -i 21600 -s 20

lsof -p 14527:
[snip]
chef-clie 14527 root 0u CHR 136,0 2 /dev/pts/0
chef-clie 14527 root 1u CHR 136,0 2 /dev/pts/0
chef-clie 14527 root 2u CHR 136,0 2 /dev/pts/0
chef-clie 14527 root 3r FIFO 0,6 23443298 pipe
chef-clie 14527 root 4w FIFO 0,6 23443298 pipe

the way i’m invoking it on the commandline is like so:

[root@proxy1-dev /]# chef-client
[Wed, 02 Nov 2011 00:53:30 +0000] INFO: *** Chef 0.10.4 ***
[Wed, 02 Nov 2011 00:53:32 +0000] INFO: Run List is [role[base], role[mail-client],[snip]
[snip]
[Wed, 02 Nov 2011 00:54:35 +0000] INFO: Running report handlers
[Wed, 02 Nov 2011 00:54:35 +0000] INFO: Report handlers complete
… ctrl-c issued here
[Wed, 02 Nov 2011 00:58:00 +0000] FATAL: SIGINT received, stopping
[root@proxy1-dev /]#

lsof -p 4205, the daemon, fwiw:
[snip]
chef-clie 4205 root 0r CHR 1,3 780 /dev/null
chef-clie 4205 root 1w CHR 1,3 780 /dev/null
chef-clie 4205 root 2w CHR 1,3 780 /dev/null
chef-clie 4205 root 3w REG 8,1 571850 937490 /var/log/chef/chef.log
chef-clie 4205 root 4r FIFO 0,6 23403940 pipe
chef-clie 4205 root 5w FIFO 0,6 23403940 pipe
chef-clie 4205 root 6w REG 8,1 45549 937784 /var/log/chef/client.log
chef-clie 4205 root 7r FIFO 0,6 23411440 pipe
chef-clie 4205 root 8w FIFO 0,6 23411440 pipe
chef-clie 4205 root 12r FIFO 0,6 23411409 pipe

On Tue, Nov 1, 2011 at 9:09 PM, kallen@groknaut.net wrote:

the way i'm invoking it on the commandline is like so:

[root@proxy1-dev /]# chef-client
[Wed, 02 Nov 2011 00:53:30 +0000] INFO: *** Chef 0.10.4 ***
[Wed, 02 Nov 2011 00:53:32 +0000] INFO: Run List is [role[base], role[mail-client],[snip]
[snip]
[Wed, 02 Nov 2011 00:54:35 +0000] INFO: Running report handlers
[Wed, 02 Nov 2011 00:54:35 +0000] INFO: Report handlers complete
... ctrl-c issued here
[Wed, 02 Nov 2011 00:58:00 +0000] FATAL: SIGINT received, stopping
[root@proxy1-dev /]#

Have you tried running 'chef-client -l debug'? Can you post the last
few lines of output from that?

Bryan

On Wed, 02 Nov 2011, Bryan McLellan wrote:

On Tue, Nov 1, 2011 at 9:09 PM, kallen@groknaut.net wrote:

the way i'm invoking it on the commandline is like so:

[root@proxy1-dev /]# chef-client
[Wed, 02 Nov 2011 00:53:30 +0000] INFO: *** Chef 0.10.4 ***
[Wed, 02 Nov 2011 00:53:32 +0000] INFO: Run List is [role[base], role[mail-client],[snip]
[snip]
[Wed, 02 Nov 2011 00:54:35 +0000] INFO: Running report handlers
[Wed, 02 Nov 2011 00:54:35 +0000] INFO: Report handlers complete
... ctrl-c issued here
[Wed, 02 Nov 2011 00:58:00 +0000] FATAL: SIGINT received, stopping
[root@proxy1-dev /]#

Have you tried running 'chef-client -l debug'? Can you post the last
few lines of output from that?

11/02 19:09[root@proxy1-trex ~]# chef-client -l debug
[Wed, 02 Nov 2011 19:09:39 +0000] INFO: *** Chef 0.10.4 ***
[Wed, 02 Nov 2011 19:09:39 +0000] DEBUG: Loading plugin os
[Wed, 02 Nov 2011 19:09:39 +0000] DEBUG: Loading plugin kernel
[Wed, 02 Nov 2011 19:09:39 +0000] DEBUG: Loading plugin ruby
[snip]
[Wed, 02 Nov 2011 19:10:43 +0000] DEBUG: Removing unused checksum cache file /var/chef/cache/checksums/chef-file--tmp-chef-rendered-template20111102-4205-h8ebct-0
[Wed, 02 Nov 2011 19:10:43 +0000] INFO: Running report handlers
[Wed, 02 Nov 2011 19:10:43 +0000] INFO: Report handlers complete
[Wed, 02 Nov 2011 19:10:43 +0000] DEBUG: Sleeping for 21600 seconds
"hung" .... ctrl-c
[Wed, 02 Nov 2011 19:12:21 +0000] FATAL: SIGINT received, stopping

On Wednesday, November 2, 2011 at 12:13 PM, kallen@groknaut.net wrote:

11/02 19:09[root@proxy1-trex ~]# chef-client -l debug
[Wed, 02 Nov 2011 19:09:39 +0000] INFO: *** Chef 0.10.4 ***
[Wed, 02 Nov 2011 19:09:39 +0000] DEBUG: Loading plugin os
[Wed, 02 Nov 2011 19:09:39 +0000] DEBUG: Loading plugin kernel
[Wed, 02 Nov 2011 19:09:39 +0000] DEBUG: Loading plugin ruby
[snip]
[Wed, 02 Nov 2011 19:10:43 +0000] DEBUG: Removing unused checksum cache file /var/chef/cache/checksums/chef-file--tmp-chef-rendered-template20111102-4205-h8ebct-0
[Wed, 02 Nov 2011 19:10:43 +0000] INFO: Running report handlers
[Wed, 02 Nov 2011 19:10:43 +0000] INFO: Report handlers complete
[Wed, 02 Nov 2011 19:10:43 +0000] DEBUG: Sleeping for 21600 seconds
"hung" .... ctrl-c
[Wed, 02 Nov 2011 19:12:21 +0000] FATAL: SIGINT received, stopping

As long as you have the interval setting configured in your client.rb or set from the command line, Chef will infer that you want it to loop. Using the --once command line option will turn off looping even if you have an interval set in your config somewhere.

cf. https://github.com/opscode/chef/blob/master/chef/lib/chef/application/client.rb#L167-170

HTH,

--
Dan DeLeo

On Wed, Nov 2, 2011 at 3:13 PM, kallen@groknaut.net wrote:

[Wed, 02 Nov 2011 19:10:43 +0000] DEBUG: Sleeping for 21600 seconds

On Wed, Nov 2, 2011 at 3:27 PM, Daniel DeLeo dan@kallistec.com wrote:

As long as you have the interval setting configured in your client.rb or set from the command line, Chef will infer that you want it to loop. Using the --once command line option will turn off looping even if you have an interval set in your config somewhere.

Right, so normally you don't need to provide "--once" to a chef-client
one, but if you have an interval set in your /etc/chef/client.rb, the
client is picking that up and running in a loop. You probably didn't
always have an interval configured, but then decided to change it from
the default interval, so now all chef-client runs, daemonized and from
the command line, are running in loop mode.

Bryan

On Wed, 02 Nov 2011, Bryan McLellan wrote:

On Wed, Nov 2, 2011 at 3:13 PM, kallen@groknaut.net wrote:

[Wed, 02 Nov 2011 19:10:43 +0000] DEBUG: Sleeping for 21600 seconds

On Wed, Nov 2, 2011 at 3:27 PM, Daniel DeLeo dan@kallistec.com wrote:

As long as you have the interval setting configured in your client.rb or set from the command line, Chef will infer that you want it to loop. Using the --once command line option will turn off looping even if you have an interval set in your config somewhere.

Right, so normally you don't need to provide "--once" to a chef-client
one, but if you have an interval set in your /etc/chef/client.rb, the
client is picking that up and running in a loop. You probably didn't
always have an interval configured, but then decided to change it from
the default interval, so now all chef-client runs, daemonized and from
the command line, are running in loop mode.

yep. that must be it. fairly recently i had a need to alter the default
interval. one day i'll go back to default, but not yet.

thanks!

On Tuesday, November 1, 2011 at 6:09 PM, kallen@groknaut.net wrote:

hi. when i run chef-client on the cmdline, it won't exit, it holds open
my pts. shouldn't it exit? when the cmdline run is complete, i have to
ctrl-c to get my prompt back.

is using the "--once" switch the proper thing to do? if memory serves,
i didn't used to have to do that. maybe that was a prior release..

Yes, use --once -- that's exactly what it's for. This is necessary because Chef treats the presence of an interval setting as an indication that it should loop, and we can't use the daemonize setting for this since you may want to run Chef in a loop in the foreground when using some process supervisor tools (such as runit).

HTH,

--
Dan DeLeo

On Nov 1, 2011, at 8:40 PM, Daniel DeLeo wrote:

is using the "--once" switch the proper thing to do? if memory serves,
i didn't used to have to do that. maybe that was a prior release..

Yes, use --once -- that's exactly what it's for. This is necessary because Chef treats the presence of an interval setting as an indication that it should loop, and we can't use the daemonize setting for this since you may want to run Chef in a loop in the foreground when using some process supervisor tools (such as runit).

That's weird, because his chef-client instance that he has that is already running in the background is using the -i flag, but the instance he's running from the command line is not. I'm in that same situation myself, and yet for me the copy of chef-client that I run from the command line does exit when the single run is complete.

--
Brad Knowles bknowles@ihiji.com
SAGE Level IV, Chef Level 0.0.1