Friday, February 7, 2014

Running Multiple Instances of CGWatcher on the Same Computer

Running Multiple Instances of CGWatcher

Running multiple instances of CGWatcher means you can have a CGWatcher instance monitoring each cgminer/bfgminer instance. There are two things you need to do for this to work correctly - have unique folders and have unique ports. I'll explain in detail so although it might be a lot of text, it is very simple. You can run as many instances as you need.

1. Each CGWatcher instance must have its own folder. This is so they do not overwrite each other's settings, and also so the Windows autorun entries will be unique. You can put the folders anywhere, including nesting them inside each other. So if you want to run two instances, A and B, the following examples would work:

  • CGWatcher A - C:\Miners\CGWatcherA
  • CGWatcher B - C:\Miners\CGWatcherB
or
  • CGWatcher A - C:\Miners\CGWatcherA
  • CGWatcher B - C:\Miners\CGWatcherA\CGWatcherB
or
  • CGWatcher A - C:\Miners\CGWatcher
  • CGWatcher B - C:\Miners\CGWatcher\CGWatcher

If you want to share the same profiles between instances, you can set them to use the same profiles.dat file by editing CGWatcher.exe.ini in each folder. In this file, locate the line that says "ProfilesDataFile=" and add the file path of the profiles.dat file you want it to use. Do not use quotes in the file path. Example: ProfilesDataFile=C:\My Miners Folder\CGWatcher\profiles.dat  

When ProfilesDataFile= is blank, CGWatcher will use (or create) the profiles.dat file in the same folder it is in. You can also do the same with CGWatcher variables by setting the VariablesDataFile path.


2. Each instance must use a unique API port so it always communicates with the correct miner. To set the API port, go to the Settings tab in CGWatcher. In the bottom, left, locate 'Miner API Address (IP:port)' textbox. The port is the number after the colon. This number must be unique for each instance. So instance A could be 4028 (cgminer's default API port) and instance B could be 4029. You can use any number between 1024 and 65535 - it just has to be a port that isn't being used by another application. The IP address stays the same - 127.0.0.1 - for all instances. So the textbox for your CGWatcher instances would be:

CGWatcher A:   127.0.0.1:4028
CGWatcher B:   127.0.0.1:4029

Once you have entered a unique port, check the checkbox below it that says 'Use only this API port (override config settings)'. When this is enabled, CGWatcher will ensure that cgminer/bfgminer always uses this port - even if the config file says to use a different port. This ensures that multiple instances will never cross communicate.

Now since each CGWatcher instance has its own file path, if you enable 'Run when Windows starts' an entry will be created for each instance.

Click Save Settings.

I do this on my own computer since it mines scrypt coins with GPUs and Bitcoin with ASICs. I then just create a shortcut to each CGWatcher instance on the desktop and rename them to "CGWatcher GPU" and one "CGWatcher ASIC". I have them sharing the same profiles file, so if you make changes to profiles in one, it is picked up by the other one (it may take up to 15 minutes for this to happen, but it will always check for changes before starting the miner).

Also, you can obviously share config files between instances but you can share config files between miners as well. More info on this and using variables can be found at http://manotechnology.blogspot.com/2013/08/web-config-files.html

In the future I may try to come up with a better way to do this, but it is getting to where CGRemote will probably be a better way to do this since it is built from the ground up to handle multiple miners. CGWatcher was designed to only watch one process at a time, and I think my time would be better spent working on putting CGWatcher features into CGRemote than rewriting CGWatcher.