Check if sharedcache windows service is running

Jun 18, 2009 at 11:40 AM

Hi

Is their any recommended way that I cacn check if the sharedcache is running.

I tried the IndexusDistributionCache.SharedCache.GetStats after stopping the service, but it just returns that their were no objects in the cache. What I really wanted was to check if the service is down for some reasons

 

Regards

Lars Kolsaker

Making Waves as

Jun 18, 2009 at 5:24 PM

hi lars,

you could use WMI for retrieving the service status or you can do it programatically, check out the following link: http://www.smoothdesigners.com/2008/10/checking-service-status-in-c/ 

as much as i have heared from other people there are normally using monitoring tools to check if the service is running.

regards,

roni 

Oct 15, 2009 at 5:51 PM

You can also try using the System.ServiceProcess.ServiceController class.  It's got nice simple methods and properties to query and control services on your local or remote machines.  Be sure to add a reference to System.ServiceProcess.

Oct 29, 2009 at 11:20 PM

If you just want to check if any/all the server nodes are running without controlling the service, you can just call Ping().

IndexusProviderBase provider = IndexusDistributionCache.SharedCache;

foreach ( string server in provider.Servers )
                Console.WriteLine( "{0} = {1}", server, provider.Ping( server ) );

Nov 2, 2009 at 1:23 PM

I would recommend the ping mechanism as the service still runs even when the TCPServer stops responding. You could then restart the service using the ServiceController class.