how to run multiple instances of a windows service

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi!!!

i want to make 1 windows service and be able to run like 20 independent
instances of this.

the main reason i want this is to be able to see the names of the processes
running and to be able to restart the processes that has crashed.

is it a way to do this ?
 
This is kind of a loaded question; running 20 instances of the same
executable for crash-proofing is like using 20 garbage trucks to pick up the
trash in your kitchen trash container. There are much more robust ways to
wire up a single service for crash-proofing, not limited to good exception
handling, Syslog messaging, and setting the recovery options in the Service
Manager to restart the service if it fails.

Having said that, the only requirement is that the ServiceName property in
the installer and the Windows service class must be different. And of course,
the actual executables must be located in separate folders.

Peter
 
hi!!!

ok. so you suggest that i run several services in the same process ?
how do i restart the services that crash ?

Geir Sanne
 
ok. so you suggest that i run several services in the same process ?

I think, with respect, that Peter is not suggesting that at all, but rather
suggesting that you take a step back here and fix the bugs that are causing
your service to crash in the first place...
 
how do i restart the services that crash ?

Via the Service Control Manager dialog, right click the service, goto the
recovery tab, and change the
First failure, Second Failure and Subsequent failure drop downs.


If you want code to do this, let me know and I can post it.


Dave
 
i finally got everything to work.

what i had to do is subclass my testservice
myservice1 through myservice30 is subclassed from testservice.

then i can read from a config file how many of the myserviceX services i
should install. is it a better way to do this ?

the second problem is that i might want to delete som services or install
new ones.
how can i do this without stopping the other services ?

-Geir
 
Back
Top