Merge pull request #92 from BretFisher/master

prevent dotnet worker from consuming all cpu
This commit is contained in:
Mano Marks 2017-11-21 13:37:17 -08:00 committed by GitHub
commit 3a5539927b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -1,5 +1,6 @@
FROM node:8.9-slim FROM node:8.9-slim
RUN apt-get update -qq && apt-get install -qy \
RUN apt-get update -qq && apt-get install -qy \
ca-certificates \ ca-certificates \
bzip2 \ bzip2 \
curl \ curl \

View File

@ -28,6 +28,9 @@ namespace Worker
var definition = new { vote = "", voter_id = "" }; var definition = new { vote = "", voter_id = "" };
while (true) while (true)
{ {
// Slow down to prevent CPU spike, only query each 100ms
Thread.Sleep(100);
// Reconnect redis if down // Reconnect redis if down
if (redisConn == null || !redisConn.IsConnected) { if (redisConn == null || !redisConn.IsConnected) {
Console.WriteLine("Reconnecting Redis"); Console.WriteLine("Reconnecting Redis");