Go Back   ZeroC Forums > Help Center

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 09-07-2006
Powell Trusler Powell Trusler is offline
Registered User
 
 
Join Date: Sep 2006
Posts: 8
Windows Service suggestions

Hello all,
I am working on an Ice C# windows service(ServiceBase). I want to make sure I am opening and closing connections, freeing up resources, etc properly.
I approached it like this:

In service class, onStart method I invoke run method of my Ice.Application class.
Within the run method I create a communicator, then object adapter, and then activate the adapter.

The service seems to work fine, although I am not 100% sure I have done all that is needed.

Can anyone talk me through the reccomended or correct way to provide Ice service functionality through a Windows service?

Thanks a million!,
Powell
__________________
Powell Trusler
CitiGroup
Enterprise Infrastructure Tools
Reply With Quote
  #2 (permalink)  
Old 09-07-2006
michi's Avatar
michi michi is offline
ZeroC Staff
 
Name: Michi Henning
Organization: ZeroC
Project: Ice
 
Join Date: Feb 2003
Location: Brisbane, Australia
Posts: 931
Quote:
Originally Posted by Powell Trusler
Hello all,
Within the run method I create a communicator, then object adapter, and then activate the adapter.

The service seems to work fine, although I am not 100% sure I have done all that is needed.
When you derive from ServiceBase, you normally initialize the Ice run time in the OnStart() method, and tear it down again in the OnStop() method.

You can do the same for OnPause() and OnContinue(). Alternatively you can put the adapters into the holding state in response to onPause() and back into the active state in OnContinue(). The up-side of doing this is that it is transparent to clients (at least up to a point) because a paused service looks like a slow service to clients. On the down-side, it can cause clients to get suspended if they keep sending requests because the TCP/IP flow control can cause the client-side transport buffers to fill up. (Depending on timeout settings, clients may also experience timeouts.) However, in general, putting all adapters into the holding state is probably the most appropriate thing to do.

Cheers,

Michi.
Reply With Quote
  #3 (permalink)  
Old 09-29-2006
Powell Trusler Powell Trusler is offline
Registered User
 
 
Join Date: Sep 2006
Posts: 8
I am using C# and SSL for my service.
I have a console app that has all the same functionality that works like a charm.
My service works fine when I use a simple tcp setup, but when I try the service with an SSL setup, I have problems.
I think I am having difficulty figuring out how to point my service code to my config file.
In a console app, it is easy to point to a config, like so:
public static void Main(string[] args)
{
server app = new server();
int status = app.main(args, @"config.server");
....

I am having trouble determining where to do this in a windows service(ServiceBase).
Any advice greatly appreciated.

Thanks,
Powell
__________________
Powell Trusler
CitiGroup
Enterprise Infrastructure Tools
Reply With Quote
  #4 (permalink)  
Old 09-29-2006
mes's Avatar
mes mes is offline
ZeroC Staff
 
Name: Mark Spruiell
Organization: ZeroC, Inc.
Project: Ice Developer
 
Join Date: Feb 2003
Location: California
Posts: 976
Hi,

A Windows service generally uses the system directory as its default working directory, so you have to be careful when specifying a relative pathname. I recommend using an absolute pathname instead, such as C:\MyService\config.server. You also must make sure that the service has sufficient privilege to access the configuration file. I discussed these issues in a newsletter article.

Take care,
- Mark
Reply With Quote
  #5 (permalink)  
Old 09-29-2006
Powell Trusler Powell Trusler is offline
Registered User
 
 
Join Date: Sep 2006
Posts: 8
I have used fully qualified paths, but still no luck.
My question is to how or where the config file is specified in a windows service.

Thanks,
Powell
__________________
Powell Trusler
CitiGroup
Enterprise Infrastructure Tools
Reply With Quote
  #6 (permalink)  
Old 09-29-2006
mes's Avatar
mes mes is offline
ZeroC Staff
 
Name: Mark Spruiell
Organization: ZeroC, Inc.
Project: Ice Developer
 
Join Date: Feb 2003
Location: California
Posts: 976
Quote:
Originally Posted by Powell Trusler
My question is to how or where the config file is specified in a windows service.
The easiest way is to include it as part of the service's command-line options, such as

myservice --Ice.Config=C:\MyService\config.server

In C++, the Ice::Service class allows you to install a service and include whatever command-line arguments are necessary. You would probably have to implement support for this yourself in C#.

Your service can also determine the location of the configuration file at run time and then define Ice.Config or load the properties manually.

Take care,
- Mark
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
why I can't start icebox as as a Windows service? kexi Help Center 1 01-18-2007 01:02 AM
Windows service and config file Powell Trusler Help Center 1 10-10-2006 01:12 PM
Using Ice.Config with a Windows Service iamwoodyjones Help Center 9 09-26-2006 12:14 PM
Glacier2 service not starting on Windows XP rhochmuth Help Center 3 02-08-2005 01:19 PM
ICE Windows Service amrufon Help Center 5 07-16-2004 09:17 AM


All times are GMT -4. The time now is 12:40 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
(c) 2008 ZeroC, Inc.