protected virtual void ExecMinerCustomActionSettings(bool startTrueStopFalse) { if (MinerCustomActionSettings == null || !MinerCustomActionSettings.UseUserSettings) { return; } if (MinerCustomActionSettings.AlgorithmCustomActions == null) { return; } try { var(actionScriptsKey, ok) = MinerToolkit.GetAlgorithmSettingsKey(_miningPairs); if (!ok) { return; } 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}"); } }
protected virtual Dictionary <string, string> GetEnvironmentVariables() { if (MinerSystemEnvironmentVariables == null) { return(null); } var(customSettingKey, ok) = MinerToolkit.GetAlgorithmSettingsKey(_miningPairs); if (ok && (MinerSystemEnvironmentVariables.CustomSystemEnvironmentVariables?.ContainsKey(customSettingKey) ?? false)) { return(MinerSystemEnvironmentVariables.CustomSystemEnvironmentVariables[customSettingKey]); } return(MinerSystemEnvironmentVariables.DefaultSystemEnvironmentVariables); }
/// <summary> /// Provides available port for miner API binding /// </summary> public virtual int GetAvaliablePort() { Dictionary <string, List <int> > reservedPorts = null; if (MinerReservedApiPorts != null && MinerReservedApiPorts.UseUserSettings) { reservedPorts = MinerReservedApiPorts.AlgorithmReservedPorts; } var(reservedPortsKey, ok) = MinerToolkit.GetAlgorithmSettingsKey(_miningPairs); if (ok && 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 }