Simple Solution to Fix the Voting Program

in blog •  7 months ago 

Previously, the voting services were not stable - with some votes missing. I have now tried a few improvements and let it run a few days, and it turns out it is quite stable now.

So TLDR; the solution is:

  1. moving to a better VPS provider i.e. hetzner
  2. run the voting service continuously in a screen session rather than a crontab.
  3. timeout the program in case it got stuck.

See following:

#!/bin/bash

i=0
while :
do
        i=$((i+1))
        date
        echo ---------------Counter $i------------------
        timeout 1200 node voting.js
        sleep 5
done

Steem to the Moon🚀!

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE BLURT!