-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
67 lines (60 loc) · 1.87 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using System;
using System.Diagnostics;
using System.Timers;
namespace StackDeployCheck
{
class Program
{
static int Main(string[] args)
{
if (args.Length < 1)
{
Console.Error.WriteLine("dotnet stack-deploy-check {stackName} [timeout seconds] [stableTime seconds]");
return -2;
}
var stackName = args[0];
int timeout = 10000;
int stableTime = 10000;
if (args.Length > 1)
{
if (!int.TryParse(args[1], out timeout))
{
Console.Error.WriteLine("ERROR: Invalid timeout!");
return -3;
}
timeout = timeout * 1000;
}
if (args.Length > 2)
{
if (!int.TryParse(args[2], out stableTime))
{
Console.Error.WriteLine("ERROR: Invalid stableTime!");
return -3;
}
stableTime = stableTime * 1000;
}
Timer timer = new Timer(timeout);
timer.Elapsed += Timer_Elapsed;
timer.Start();
var stackChecker = new StackChecker()
{
StackName = stackName
};
if (stackChecker.AwaitDesiredStates2(stableTime))
{
Console.Out.WriteLine("All stack tasks are running.");
}
else
{
Console.Error.WriteLine("ERROR: Not all stack tasks completed successfully.");
return -1;
}
return 0;
}
private static void Timer_Elapsed(object sender, ElapsedEventArgs e)
{
Console.Error.WriteLine("ERROR: Timed out waiting for desired state!");
Environment.Exit(-3);
}
}
}