Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IW14 Indy - Running multiple services of the same executable
#1
As per the subject line, really. Is it possible to run multiple services via the same executable? We see some hard dependencies between the application name and the service name that makes this difficult.

At the moment we have have an app that binds to a port on the command line, e.g. AppName.exe -port=1234.

This can be installed as a service via the /install flag or using sc.exe happily as long as the service name matches AppName.

If I want to run multiple versions, they don't work as the service name doesn't match.

E.g.
Works on service start/stop: sc create AppName binPath= "c:\path\AppName.exe -port=1234"
Hangs on service start: sc create AppName2 binPath= "c:\path\AppName.exe -port=3456"

Any suggestions or ways to achieve this?
Reply
#2
I dont believe the Delphi service classes are designed to provide 2 services from a single exe. ServiceName is a parameter I think in the Delphi service classes and likely needs updated to match during install. Its been many years since I've touched the Delphi service code.

However if you instead simply need to provide 2 distinct Indy servers, or one that listens on 2 ports at the same time that is easy to do.
Reply
#3
Hi Kudzu, thanks for the quick answer, unfortunately listening on two simultaneous ports doesn't match our use-cases:

- Redundancy; two discrete services for load balancing in case one fails; we've a high usage and highly available app that needs to survive a failure. We can spread it out over multiple machines but was also hoping to cater for in-system failures.
- Multi-tenancy; same code base, two different configurations. We can't do this through the same application unfortunately.
Reply
#4
(10-04-2019, 12:32 AM)nunnsie Wrote: Hi Kudzu, thanks for the quick answer, unfortunately listening on two simultaneous ports doesn't match our use-cases:

- Redundancy; two discrete services for load balancing in case one fails; we've a high usage and highly available app that needs to survive a failure. We can spread it out over multiple machines but was also hoping to cater for in-system failures.
- Multi-tenancy; same code base, two different configurations. We can't do this through the same application unfortunately.

We load balance 8 servers behind a barracuda load balancer that serve more than 100,000 users.   You will probably need to do something along those lines.
Reply
#5
Solution found, it's being bound by the AppName. By adding that in as a parm and ensuring it matches the proper application name, things work well.

E.g.
sc.exe create AppName_8000 binPath= "C:\path\AppName.exe -port=8000 -AppName=AppName"
sc.exe create AppName_8001 binPath= "C:\path\AppName.exe -port=8001 -AppName=AppName"

Works happily.
Reply
#6
(10-03-2019, 02:17 PM)kudzu Wrote: I dont believe the Delphi service classes are designed to provide 2 services from a single exe.

You can have multiple TService classes in the same EXE, and they are registered by default to run in separate processes when started by the SCM.

Running multiple instances of the same TService class is not "officially" supported, but that is very easy to work around by simply manipulating the TService.Name property at runtime, such as the TService.OnCreate event using command-line parameters to specify the desired name so multiple instances are registered in the SCM with different names.

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)