Hi all,
I have used the win32com libraries to set up a service called
MyService under Windows. So far, so good. Now I need to run multiple
copies of the service on the same machine. I also have that working.
For monitoring and logging, I'd like each instance of the service to
know it's own identity (MyService1, MyService2, etc.)
But I can't quite seem to grasp how to do this. In the code below,
the command line parameter "-i" gives the service an identity, but how
do I get the service to understand it's identity when it is started?
Many thanks!
class MyService(win32serviceutil.ServiceFramework):
"""NT Service."""
_svc_name_ = "MyService"
_svc_display_name_ = "My Service"
_id_ = ''
def SvcDoRun(self):
provider = MyServiceClass(identifier=self._id_)
provider.start()
# now, block until our event is set...
win32event.WaitForSingleObject(self.stop_event,
win32event.INFINITE)
# __init__ and SvcStop snipped
################################################## #########################
if __name__ == '__main__':
import optparse
parser = optparse.OptionParser()
parser.add_option("-i", "--identifier", dest="identifier")
(opts, args) = parser.parse_args()
if opts.number is not None:
MyService._svc_name_ += opts.identifier
MyService._svc_display_name_ += opts.identifier
MyService._provider_id_ = opts.identifier
win32serviceutil.HandleCommandLine(MyService,
customInstallOptions="i:") 4 4676
Chris Curvey wrote:
Hi all,
I have used the win32com libraries to set up a service called
MyService under Windows. So far, so good. Now I need to run multiple
copies of the service on the same machine. I also have that working.
For monitoring and logging, I'd like each instance of the service to
know it's own identity (MyService1, MyService2, etc.)
But I can't quite seem to grasp how to do this. In the code below,
the command line parameter "-i" gives the service an identity, but how
do I get the service to understand it's identity when it is started?
Many thanks!
class MyService(win32serviceutil.ServiceFramework):
"""NT Service."""
_svc_name_ = "MyService"
_svc_display_name_ = "My Service"
_id_ = ''
def SvcDoRun(self):
provider = MyServiceClass(identifier=self._id_)
provider.start()
# now, block until our event is set...
win32event.WaitForSingleObject(self.stop_event,
win32event.INFINITE)
# __init__ and SvcStop snipped
################################################## #########################
if __name__ == '__main__':
import optparse
parser = optparse.OptionParser()
parser.add_option("-i", "--identifier", dest="identifier")
(opts, args) = parser.parse_args()
if opts.number is not None:
MyService._svc_name_ += opts.identifier
MyService._svc_display_name_ += opts.identifier
MyService._provider_id_ = opts.identifier
win32serviceutil.HandleCommandLine(MyService,
customInstallOptions="i:")
What is your use case for this? Why not make a single server
process multiple providers (store them in a list or other
container)?
-Larry Bates
On Feb 1, 2:10 pm, Larry Bates <larry.ba...@websafe.comwrote:
Chris Curvey wrote:
Hi all,
I have used the win32com libraries to set up a service called
MyService under Windows. So far, so good. Now I need to run multiple
copies of the service on the same machine. I also have that working.
For monitoring and logging, I'd like each instance of the service to
know it's own identity (MyService1, MyService2, etc.)
But I can't quite seem to grasp how to do this. In the code below,
the command line parameter "-i" gives the service an identity, but how
do I get the service to understand it's identity when it is started?
Many thanks!
class MyService(win32serviceutil.ServiceFramework):
"""NT Service."""
_svc_name_ = "MyService"
_svc_display_name_ = "My Service"
_id_ = ''
def SvcDoRun(self):
provider = MyServiceClass(identifier=self._id_)
provider.start()
# now, block until our event is set...
win32event.WaitForSingleObject(self.stop_event,
win32event.INFINITE)
# __init__ and SvcStop snipped
################################################## #########################
if __name__ == '__main__':
import optparse
parser = optparse.OptionParser()
parser.add_option("-i", "--identifier", dest="identifier")
(opts, args) = parser.parse_args()
if opts.number is not None:
MyService._svc_name_ += opts.identifier
MyService._svc_display_name_ += opts.identifier
MyService._provider_id_ = opts.identifier
win32serviceutil.HandleCommandLine(MyService,
customInstallOptions="i:")
What is your use case for this? Why not make a single server
process multiple providers (store them in a list or other
container)?
-Larry Bates
The use case is that I have a queue of jobs that need to run. My
service connects to a central "distributor" server, which hands out
jobs to complete. I'd like to be able to run multiple copies of the
distributed service so that I can make the most use of each machine
where they run. (I'm not certain of the thread safety of some of the
libraries I'm using, so I'm leery of going the multi-threaded route)
Anyway, when my service gets a job to process, I'd like to know which
copy of the service is working on which job. So I want my log
messages to look like this:
Job 123: Host: alpha Service: MyService A
Job 124: Host: alpha Service: MyService B
Job 124: Host: beta Service: MyService C
Is that clear, or have I muddied the waters?
On 1 Feb 2007 11:24:13 -0800, Chris Curvey <cc*****@gmail.comwrote:
On Feb 1, 2:10 pm, Larry Bates <larry.ba...@websafe.comwrote:
Chris Curvey wrote:
Hi all,
I have used the win32com libraries to set up a service called
MyService under Windows. So far, so good. Now I need to run multiple
copies of the service on the same machine. I also have that working.
For monitoring and logging, I'd like each instance of the service to
know it's own identity (MyService1, MyService2, etc.)
But I can't quite seem to grasp how to do this. In the code below,
the command line parameter "-i" gives the service an identity, but how
do I get the service to understand it's identity when it is started?
Many thanks!
class MyService(win32serviceutil.ServiceFramework):
"""NT Service."""
_svc_name_ = "MyService"
_svc_display_name_ = "My Service"
_id_ = ''
def SvcDoRun(self):
provider = MyServiceClass(identifier=self._id_)
provider.start()
# now, block until our event is set...
win32event.WaitForSingleObject(self.stop_event,
win32event.INFINITE)
# __init__ and SvcStop snipped
################################################## #########################
if __name__ == '__main__':
import optparse
parser = optparse.OptionParser()
parser.add_option("-i", "--identifier", dest="identifier")
(opts, args) = parser.parse_args()
if opts.number is not None:
MyService._svc_name_ += opts.identifier
MyService._svc_display_name_ += opts.identifier
MyService._provider_id_ = opts.identifier
win32serviceutil.HandleCommandLine(MyService,
customInstallOptions="i:")
What is your use case for this? Why not make a single server
process multiple providers (store them in a list or other
container)?
-Larry Bates
The use case is that I have a queue of jobs that need to run. My
service connects to a central "distributor" server, which hands out
jobs to complete. I'd like to be able to run multiple copies of the
distributed service so that I can make the most use of each machine
where they run. (I'm not certain of the thread safety of some of the
libraries I'm using, so I'm leery of going the multi-threaded route)
Anyway, when my service gets a job to process, I'd like to know which
copy of the service is working on which job. So I want my log
messages to look like this:
Job 123: Host: alpha Service: MyService A
Job 124: Host: alpha Service: MyService B
Job 124: Host: beta Service: MyService C
Is that clear, or have I muddied the waters?
Windows services are identified by name, so if you're running multiple
services they will need to have unique _svc_name members.
Chris Curvey wrote:
On Feb 1, 2:10 pm, Larry Bates <larry.ba...@websafe.comwrote:
>Chris Curvey wrote:
>>Hi all, I have used the win32com libraries to set up a service called MyService under Windows. So far, so good. Now I need to run multiple copies of the service on the same machine. I also have that working. For monitoring and logging, I'd like each instance of the service to know it's own identity (MyService1, MyService2, etc.) But I can't quite seem to grasp how to do this. In the code below, the command line parameter "-i" gives the service an identity, but how do I get the service to understand it's identity when it is started? Many thanks! class MyService(win32serviceutil.ServiceFramework): """NT Service.""" _svc_name_ = "MyService" _svc_display_name_ = "My Service" _id_ = '' def SvcDoRun(self): provider = MyServiceClass(identifier=self._id_) provider.start() # now, block until our event is set... win32event.WaitForSingleObject(self.stop_event, win32event.INFINITE) # __init__ and SvcStop snipped ################################################ ########################### if __name__ == '__main__': import optparse parser = optparse.OptionParser() parser.add_option("-i", "--identifier", dest="identifier") (opts, args) = parser.parse_args() if opts.number is not None: MyService._svc_name_ += opts.identifier MyService._svc_display_name_ += opts.identifier MyService._provider_id_ = opts.identifier win32serviceutil.HandleCommandLine(MyService, customInstallOptions="i:")
What is your use case for this? Why not make a single server process multiple providers (store them in a list or other container)?
-Larry Bates
The use case is that I have a queue of jobs that need to run. My
service connects to a central "distributor" server, which hands out
jobs to complete. I'd like to be able to run multiple copies of the
distributed service so that I can make the most use of each machine
where they run. (I'm not certain of the thread safety of some of the
libraries I'm using, so I'm leery of going the multi-threaded route)
Anyway, when my service gets a job to process, I'd like to know which
copy of the service is working on which job. So I want my log
messages to look like this:
Job 123: Host: alpha Service: MyService A
Job 124: Host: alpha Service: MyService B
Job 124: Host: beta Service: MyService C
Is that clear, or have I muddied the waters?
Ok, makes more sense now. You will be running each service on a different
computer. If I'm understanding all you need is to supply an attribute
to the service that represents its internal name (the one you will use
to do the logging). If I wanted to do this I would create a .INI file
and read it (using ConfigParser) during service class __init__ method.
Assign self.servicename=<value from .INI file>. Then use self.servicename
to do my logging. I have a service somewhat like you describe and this
works fine for me.
-Larry This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: W Akthar |
last post by:
Hi
I am trying to create a windows service which queries SQL
Server on timed intervals and depending on the results
send appointments to Outlook.
The problem lies when I try to create an...
|
by: Nathan Kovac |
last post by:
Yesterday afternoon I was getting the following errors in a windows service:
'DatabaseManager.DataComponent', 'Error', '3 Errors:
Line: 0 - Metadata file 'ScriptingMethods.dll' could not be found...
|
by: José Achig |
last post by:
Hi all,
The service I have written can not enumerate the current user's desktop
windows when running as a service.
I read where one solution to this is to install the service with...
|
by: Kristof Despiere |
last post by:
Suppose you have one domain, filled with a couple of users. What needs to be
done now is I need to start a windows application from a webform by pressing
a button on the webform (for example).
...
|
by: pberna |
last post by:
Dear all,
I built a Web Form application to start and stop a Windows Service remotely.
I successful tested the application on Windows 2000 server + IIS. I must
include the ASPNET user
to the...
|
by: Jimmy |
last post by:
Hi,
I need to develop a secure Web Service that requires a username and
password. One of the requirements is that the WS supports Windows
Authentication, meaning accepts the username and...
|
by: =?Utf-8?B?RGFuZGFuIFpoYW5n?= |
last post by:
Now I have a web application, a web service and a SQL Server database.
The Web application will invoke the web service, the web service
invokes the SQL Server stored procedure.
I let the web...
|
by: =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?= |
last post by:
I copied my portal to WIndows 2003 and now I am getting:
Server Error in '/portal' Application.
--------------------------------------------------------------------------------
The current...
|
by: Max2006 |
last post by:
Hi,
I am trying to limit my wcf service endpoint to response to only given
windows user or group. How can I do that? Is there any way to configure that
in the .config file?
Thank you,
Max
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |