hi Daniel,

i got the problem of "Why does Puppet keep trying to start a running
service?"


The ideal way to check for a service is to use the hasstatus
parameter, which calls the init script with the status parameter. This
should report back to Puppet whether the service is running or
stopped.

In some broken scripts, however, the status output will be correct
(“Ok” or “not running”), but the exit code of the script will be
incorrect. Most commonly, the script will always blindly return 0, no
matter what the actual service state is. Puppet only uses the exit
code, so interprets this as “the service is stopped”.

There are two workarounds, and one fix. If you must deal with the
scripts broken behavior as is, you can modify your resource to either
use the pattern parameter to look for a particular process name, or
the status parameter to use a custom script to check for the service
status.

The fix is to rewrite the init script to use the proper exit codes.
When rewriting them, or submitting bug reports to vendors or upstream,
be sure to reference the LSB Init Script Actions standard. This should
carry more weight by pointing out an official, published standard
they’re failing to meet, rather than trying to explain how their bug
is causing problems in Puppet.



thanks :
Sanjiv Singh(iLabs)
Impetus InfoTech.


On Nov 12, 4:21 pm, "luke.bigum" <[email protected]> wrote:
> Hi Sanjiv,
>
> This *should* not happen. Puppet will not restart a service if it's
> already running properly. I'm going to guess that the problem is
> Puppet does not KNOW that Tomcat is running properly and so thinks it
> needs to restart Tomcat every run.
>
> Does your Tomcat LSB/init script (/etc/init.d/tomcat or wherever it is
> on your distro) support the status command correctly?
>
> If it does, it should return zero if the tomcat service is running. If
> this is the case you can add "hasstatus => true" to your
> Service[Tomcat] declaration like so:
>
> service { "tomcat":
>   ensure => running,
>   hasstatus => true,
>
> }
>
> Puppet will execute the 'status check' and use it's return value to
> determine if the service is running (zero is running). For example,
> here is mysqld's script:
>
> # /etc/init.d/mysqld status
> mysqld (pid xxxxx) is running...
> # echo $?
> 0
> #
>
> The script returns zero as you can see, and Puppet does not restart
> this service every time it runs.
>
> According to the documentation (http://docs.puppetlabs.com/references/
> latest/type.html#service), if you don't specify hasstatus then Puppet
> will try determine the status of the service on it's own, usually by
> checking the process table, so if your tomcat service does not run as
> a process name of 'tomcat' this might cause problems.
>
> One last way is to manually specify a "status => cmd" and write your
> own check to determine if tomcat is running or not, but "hasstatus" is
> the way most people would go I think.
>
> -Luke
>
> On Nov 12, 11:10 am, "sanjiv.singh" <[email protected]>
> wrote:
>
> > hi all,
>
> > i m tring to use Service  resource type as following...
>
> > service { 'tomcat':
> >     ensure => running,
>
> > }
>
> > as I know , It will first stop tomcat , then start tomcat......
>
> > but my requirement is like that i do not want  to restart it ..
>
> > , i want that if tomcat is allready running , then there is no need to
> > do anything.....
> > and if stoped then , start it....
>
> > Can anybody tell  how can I get this functionality ?
>
> > Guide me if  I had any missconception.......
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to