Beispiel #1
0
        protected virtual void ExecMinerCustomActionSettings(bool startTrueStopFalse)
        {
            if (MinerCustomActionSettings == null || !MinerCustomActionSettings.UseUserSettings)
            {
                return;
            }
            if (MinerCustomActionSettings.AlgorithmCustomActions == null)
            {
                return;
            }

            try
            {
                var actionScriptsKey = MinerToolkit.GetAlgorithmPortsKey(_miningPairs);
                if (MinerCustomActionSettings.AlgorithmCustomActions.ContainsKey(actionScriptsKey) == false)
                {
                    return;
                }
                var actionsEntry = MinerCustomActionSettings.AlgorithmCustomActions[actionScriptsKey];
                if (actionsEntry == null)
                {
                    return;
                }
                var exePath       = startTrueStopFalse ? actionsEntry.StartExePath : actionsEntry.StopExePath;
                var exePathWait   = startTrueStopFalse ? actionsEntry.StartExePathWaitExec : actionsEntry.StopExePathWaitExec;
                var pcieBusParams = _miningPairs.Select(p => p.Device).Where(d => d is IGpuDevice).Cast <IGpuDevice>().Select(gpu => gpu.PCIeBusID);
                var args          = string.Join(",", pcieBusParams);
                if (exePath == null)
                {
                    return;
                }
                var startInfo = new ProcessStartInfo
                {
                    FileName  = exePath,
                    Arguments = args,
                    //CreateNoWindow = true,
                    WindowStyle = ProcessWindowStyle.Minimized
                                  //UseShellExecute = false
                };
                using (var action = Process.Start(startInfo))
                {
                    if (exePathWait)
                    {
                        // blocking
                        action.WaitForExit();
                    }
                }
            }
            catch (Exception e)
            {
                var commandType = startTrueStopFalse ? "START" : "STOP";
                Logger.Error(_logGroup, $"ExecMinerCustomActionSettings {commandType} error: {e.Message}");
            }
        }
Beispiel #2
0
        /// <summary>
        /// Provides available port for miner API binding
        /// </summary>
        public int GetAvaliablePort()
        {
            Dictionary <string, List <int> > reservedPorts = null;

            if (MinerReservedApiPorts != null && MinerReservedApiPorts.UseUserSettings)
            {
                reservedPorts = MinerReservedApiPorts.AlgorithmReservedPorts;
            }
            var reservedPortsKey = MinerToolkit.GetAlgorithmPortsKey(_miningPairs);

            if (reservedPorts != null && reservedPorts.ContainsKey(reservedPortsKey) && reservedPorts[reservedPortsKey] != null)
            {
                var reservedPortsRange = reservedPorts[reservedPortsKey];
                var port = FreePortsCheckerManager.GetAvaliablePortInRange(reservedPortsRange); // retrive custom user port
                if (port > -1)
                {
                    return(port);
                }
            }
            // if no custom port return a port in the default range
            return(FreePortsCheckerManager.GetAvaliablePortFromSettings()); // use the default range
        }