Skip to content

Commit f2b419a

Browse files
Adding K8s service definition for the other parts of WebCrawler (#12)
* implementing TrackerService K8s * came up with a better way to encode CLUSTER_IP into Lighthouse and Tracker * Added K8s YAML file for WebCrawler * fixed issue with lighthouse YAML * cluster fully forms on K8s
1 parent 556e123 commit f2b419a

18 files changed

+239
-18
lines changed

RELEASE_NOTES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#### 0.2.1 Feb 07 2019 ####
2+
* Made it possible to invoke `CoordinatedShutdown` automatically via the `AppDomain.CurrentDomain.ProcessExit` event in .NET Core on `TrackerService`, `Lighthouse`, `CrawlerService`, and the `Web` application.
3+
14
#### 0.2.0 Feb 06 2019 ####
25
Upgraded to .NET Core 2.1 for all services.
36

src/Lighthouse/Program.NetCore.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Diagnostics;
23

34
namespace Lighthouse
45
{
@@ -9,6 +10,12 @@ public static void Main(string[] args)
910
var lighthouseService = new LighthouseService();
1011
lighthouseService.Start();
1112
Console.WriteLine("Press Control + C to terminate.");
13+
14+
AppDomain.CurrentDomain.ProcessExit += async (sender, eventArgs) =>
15+
{
16+
await lighthouseService.StopAsync();
17+
};
18+
1219
Console.CancelKeyPress += async (sender, eventArgs) =>
1320
{
1421
await lighthouseService.StopAsync();

src/Lighthouse/akka.hocon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ petabridge.cmd{
1313
}
1414

1515
akka {
16+
coordinated-shutdown.exit-clr = on
1617
actor {
1718
provider = cluster
1819
}

src/WebCrawler.CrawlService/CrawlerService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ public bool Start()
2222
return true;
2323
}
2424

25-
public Task Stop()
25+
public async Task Stop()
2626
{
27-
return CoordinatedShutdown.Get(ClusterSystem).Run(CoordinatedShutdown.ClrExitReason.Instance);
27+
await CoordinatedShutdown.Get(ClusterSystem).Run(CoordinatedShutdown.ClrExitReason.Instance);
2828
}
2929
}
3030
}

src/WebCrawler.CrawlService/Dockerfile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM microsoft/dotnet:2.1-runtime AS base
1+
FROM microsoft/dotnet:2.1-sdk AS base
22
WORKDIR /app
33

44
# should be a comma-delimited list
@@ -11,5 +11,12 @@ EXPOSE 5213
1111

1212
COPY ./bin/Release/netcoreapp2.1/publish/ /app
1313

14+
# Install Petabridge.Cmd client
15+
RUN dotnet tool install --global pbm
16+
17+
# Needed because https://stackoverflow.com/questions/51977474/install-dotnet-core-tool-dockerfile
18+
ENV PATH="${PATH}:/root/.dotnet/tools"
19+
20+
RUN pbm help
1421

1522
CMD ["dotnet", "WebCrawler.CrawlService.dll"]

src/WebCrawler.CrawlService/Program.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,14 @@ static void Main(string[] args)
99
var crawlerService = new CrawlerService();
1010
crawlerService.Start();
1111

12-
Console.CancelKeyPress += (sender, eventArgs) =>
12+
AppDomain.CurrentDomain.ProcessExit += (sender, eventArgs) =>
1313
{
14-
crawlerService.Stop();
14+
crawlerService.Stop().Wait(TimeSpan.FromSeconds(30));
15+
};
16+
17+
Console.CancelKeyPress += async (sender, eventArgs) =>
18+
{
19+
await crawlerService.Stop();
1520
eventArgs.Cancel = true;
1621
};
1722

src/WebCrawler.CrawlService/WebCrawler.CrawlService.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<PackageReference Include="Akka.Bootstrap.Docker" Version="$(AkkaBootstrapVersion)" />
1616
<PackageReference Include="Akka.Cluster" Version="$(AkkaVersion)" />
1717
<PackageReference Include="Akka.Cluster.HealthCheck" Version="$(AkkaHealthCheckVersion)" />
18+
<PackageReference Include="Petabridge.Cmd.Cluster" Version="$(PetabridgeCmdVersion)" />
1819
</ItemGroup>
1920

2021
<ItemGroup>

src/WebCrawler.TrackerService/Dockerfile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM microsoft/dotnet:2.1-runtime AS base
1+
FROM microsoft/dotnet:2.1-sdk AS base
22
WORKDIR /app
33

44
# should be a comma-delimited list
@@ -11,4 +11,12 @@ EXPOSE 5212
1111

1212
COPY ./bin/Release/netcoreapp2.1/publish/ /app
1313

14+
# Install Petabridge.Cmd client
15+
RUN dotnet tool install --global pbm
16+
17+
# Needed because https://stackoverflow.com/questions/51977474/install-dotnet-core-tool-dockerfile
18+
ENV PATH="${PATH}:/root/.dotnet/tools"
19+
20+
RUN pbm help
21+
1422
CMD ["dotnet", "WebCrawler.TrackerService.dll"]

src/WebCrawler.TrackerService/Program.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,14 @@ private static void Main(string[] args)
1515
var trackingService = new TrackerService();
1616
trackingService.Start();
1717

18-
Console.CancelKeyPress += (sender, eventArgs) =>
18+
AppDomain.CurrentDomain.ProcessExit += (sender, eventArgs) =>
1919
{
20-
trackingService.Stop();
20+
trackingService.Stop().Wait(TimeSpan.FromSeconds(30));
21+
};
22+
23+
Console.CancelKeyPress += async (sender, eventArgs) =>
24+
{
25+
await trackingService.Stop();
2126
eventArgs.Cancel = true;
2227
};
2328

src/WebCrawler.TrackerService/TrackerService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ public bool Start()
3131
return true;
3232
}
3333

34-
public Task Stop()
34+
public async Task Stop()
3535
{
36-
return CoordinatedShutdown.Get(ClusterSystem).Run();
36+
await CoordinatedShutdown.Get(ClusterSystem).Run(CoordinatedShutdown.ClrExitReason.Instance);
3737
}
3838
}
3939
}

0 commit comments

Comments
 (0)