[python-win32] Multiple Windows Services
Harald Armin Massa
haraldarminmassa at gmail.com
Thu Jan 22 14:47:35 CET 2009
Nick,
guess I had a similar problem. My solution was:
[....]
cnf=oboxparm.readini()
class oboxservice(win32serviceutil.ServiceFramework):
_svc_name_=cnf.get("system","_svc_name_")
_svc_display_name_ = cnf.get("system","_svc_display_name_")
_svc_description_ = cnf.get("system","_svc_description_")
_svc_deps_ = ["EventLog",cnf.get("system","dbservice")]
def __init__(self, args):
win32serviceutil.ServiceFramework.__init__(self, args)
self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)
[....]
"oboxparm.readini()" is reading a config file in the directory of the
service.exe, and within that config file I store the name of the
service within the parameters.
That reading is done by
from ConfigParser import SafeConfigParser
giving back a configuration structure.
Hope that helps,
Harald
On Thu, Jan 22, 2009 at 14:07, Nick Leaton <nickle at gmail.com> wrote:
> I have a need to write a service that can take multiple guises.
>
> So I would like one set of code, and to be able to install a dev service, a
> uat service, a test service etc.
>
> so something like
>
> python NickService.py -environment=DEV -config=c:\config\NickService.config
>
> for the install.
>
> This would then install a NickServiceDEV service. I can then install a
> second instance of the same service.
>
> Now, I'm having problems getting the 'DEV' information and the config
> information when each service is running
>
> The idea being that given the DEV and the config file, I can look up the
> other parameters I need to use in the SvcDoRun etc
>
> 2 questions.
>
> 1. Is this the right approach? I would prefer not to go near the registry if
> possible.
> 2. If not, what is the right way?
>
>
> Thanks
>
> --
> Nick
>
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
>
>
--
GHUM Harald Massa
persuadere et programmare
Harald Armin Massa
Spielberger Straße 49
70435 Stuttgart
0173/9409607
no fx, no carrier pigeon
-
EuroPython 2009 will take place in Birmingham - Stay tuned!
More information about the python-win32
mailing list