[chef] RE: RE: Re: detect if a service is running?


Chronological Thread 
  • From: " " < >
  • To: " " < >
  • Subject: [chef] RE: RE: Re: detect if a service is running?
  • Date: Thu, 26 Mar 2015 14:53:45 +0000
  • Accept-language: en-GB, en-US

Hi James,

  I had a similar problem in that performing an upgrade on our software on Windows requires the services be stopped.

  As I wanted to make everything available under one application cookbook I also used custom ruby code and an LWRP.

The first part enumerates the services currently running by matching the service names to the app (like if the service names contain the string <mine> and that they are running, then build an array of them).

It then stops only the running services.  It also goes into a loop on each one checking it’s state has changed to stopped before stopping the next service. It does this because some files that need updating need to be not locked by another program/service.

  The upgrade then takes place and the same list used to start the services are stopped. This avoids us starting services that need to not be (we have some use cases where this is the case).

 

An LWRP was created to facilitate calling this library to make it simple and it works well.

 

Cheers

Chris

 

From: James Harrison [mailto:
Sent: 12 January 2015 16:25
To:
Subject: [chef] RE: Re: detect if a service is running?

 

HI Kenneth,

 

Thanks for the ideas!

 

To answer your specific question, the reason to reinstall a package that is installed is that it’s an upgrade installation. I should have made that much clearer J

 

I’ll look into notifies, see what I can learn from it.

 

Thanks!

 

James

 

From: Kenneth Barry [ ">mailto: ]
Sent: Friday, January 09, 2015 6:11 PM
To: ">
Subject: [chef] Re: detect if a service is running?

 

I just realized that he service in question might not be installed by the thing our installing.

 

Take a look at 'notifies', I think there is a was to have it restart a service when a block executes.

Sent from my iPhone


On Jan 9, 2015, at 3:31 PM, James Harrison < "> > wrote:

Hi chefs,

 

I’m pretty new to chef, and feel like I’m missing something obvious. Any advice would be appreciated. I’m trying to cover two scenarios with one recipe, in a Windows environment. What I’m trying to do is:

 

-          Scenario 1: install a package

-          Scenario 2: if the package is already installed, stop a service and then reinstall the package.

 

The recipe, as currently written, goes through a series of steps involving downloading the installer, always attempting to stop the service, then running the installer if the package is not already installed, then starting the service.

 

The problem I’m facing is in scenario 1. If I attempt to stop the service, but the service is not installed, then I receive an exception and execution of the recipe halts.

 

Am I trying to do something that is better covered by two recipes? Or is there some easy way to check if a service is installed?

 

Thanks

 

James



  • [chef] RE: RE: Re: detect if a service is running?, , 03/26/2015

Archive powered by MHonArc 2.6.16.

§