Skip to content

Commit c94f682

Browse files
committed
Closes #6: Wait few seconds after killing old miners and starting new.
1 parent 9247839 commit c94f682

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

xmr-stak-bootstrap/Core/Job/Miner/MinerRunnerMenuJob.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Diagnostics;
3+
using System.Threading;
34
using Unity.Attributes;
45
using XmrStakBootstrap.Common.Helper;
56
using XmrStakBootstrap.Common.Menu;
@@ -61,7 +62,11 @@ public void Execute()
6162
.AddConditionalOption(@"Start/restart miners", CanRun, () =>
6263
{
6364
Console.Clear();
64-
KillMiners(); //TODO: issue #6
65+
if (KillMiners() && RunConfigurationModel.MinerStartDelay > 0)
66+
{
67+
Console.WriteLine($@"Waiting {RunConfigurationModel.MinerStartDelay} second(s) before starting new miner(s).");
68+
Thread.Sleep(RunConfigurationModel.MinerStartDelay * 1000);
69+
}
6570
Finalizer.DoFinalize();
6671
Runner.Run(); //TODO: issue #1
6772
return false;
@@ -120,12 +125,15 @@ private void SelectWorkload()
120125
.Execute();
121126
}
122127

123-
private static void KillMiners()
128+
private static bool KillMiners()
124129
{
130+
var any = false;
125131
foreach (var process in Process.GetProcessesByName("xmr-stak"))
126132
{
133+
any = true;
127134
KillProcess(process);
128135
}
136+
return any;
129137
}
130138

131139
private static void KillProcess(Process process)

xmr-stak-bootstrap/RunConfiguration/Model/RunConfigurationModel.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ public class RunConfigurationModel
1313
[Option('w', "workload", HelpText = "Name of workload to run", SetName = "mine")]
1414
public string ActiveWorkloadConfiguration { get; set; }
1515

16+
[Option('d', "delay", HelpText = "Number of seconds to wait before terminating old miners and starting new ones", SetName = "mine", DefaultValue = 10)]
17+
public int MinerStartDelay { get; set; }
18+
1619
[Option('n', "continuous", HelpText = "Do not close bootstrapper after launching miners", SetName = "mine")]
1720
public bool ContinuousMode { get; set; }
1821

0 commit comments

Comments
 (0)