Hi,
I need to run 8 instances of the apcupsd service on a single Windows
2003 machine. Their only function is "being polled by our
Windows-based Cacti server via apcaccess.exe".
So... I was trying to run multiple instances of the apcupsd service on
a single Windows machine, each connected to a serial port and soon I
found that the windows service enforces a single instance limit.
Here's the code:
00175 // Check to see if we're already running
00176 HANDLE sem = CreateSemaphore(NULL, 0, 1, "apcupsd");
00177 if (sem == NULL || GetLastError() == ERROR_ALREADY_EXISTS) {
00178 MessageBox(NULL, "Another instance of Apcupsd is already running",
00179 "Apcupsd Error", MB_OK);
00180 return 0;
00181 }
For now I hacked around this obstacle as follows:
- create 3 copies of apcupsd.exe
- patch a different semaphore (and default config filename) into each
using hex editor
- create a .reg file for 3 apcupsd services (named apcupsA.exe,
apcupsB.exe, etc)
- make sure to specify --config-file option for each service in .reg
(don't rely on default)
- merge .reg into the registry by hand
Now edit the config file for each: apcupsA.conf, apcupsB.conf, etc and
make sure to specify a different serial port and listener ip/port for
each.
Everything seems to be working fine so far though I still need to make
sure that the services won't try to do anything besides serving up UPS
status.
So perhaps in due time the windows service could be changed to allow:
apcupsd.exe --config-file <config_file> /install
and then use a semaphore name based on the <config_file>.
I believe that setting up a build environment for apcupsd-win32 with
all of its dependencies is beyond my ability but I would be more than
happy to assist in testing this.
Cheers!
--
Jeroen "Slim" van Gelderen
------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you. Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/_______________________________________________
Apcupsd-users mailing list
Apcupsd-users@...
https://lists.sourceforge.net/lists/listinfo/apcupsd-users