Skip to content

Commit 668efb3

Browse files
author
Mano Marks
authored
Merge pull request dockersamples#92 from BretFisher/master
prevent dotnet worker from consuming all cpu
2 parents d2e2e40 + e39a11e commit 668efb3

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

result/tests/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
FROM node:8.9-slim
2-
RUN apt-get update -qq && apt-get install -qy \
2+
3+
RUN apt-get update -qq && apt-get install -qy \
34
ca-certificates \
45
bzip2 \
56
curl \

worker/src/Worker/Program.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ public static int Main(string[] args)
2828
var definition = new { vote = "", voter_id = "" };
2929
while (true)
3030
{
31+
// Slow down to prevent CPU spike, only query each 100ms
32+
Thread.Sleep(100);
33+
3134
// Reconnect redis if down
3235
if (redisConn == null || !redisConn.IsConnected) {
3336
Console.WriteLine("Reconnecting Redis");

0 commit comments

Comments
 (0)