you're reading...
cronjob, Software development

Make sure stuff is working

And we’re off!

I was quite proud of being able to incorporate my Raspberry Pi into my app, even if it was only to ping my service and populate the database. I thought it was cool, but it also gave me sleepless nights being the weakest link as the power button is in the living room, right next to the light switches. At the weekend something happened to my Pi, it didn’t seem like it was switched off, but accoring to the router there weren’t as many devices attached as usual… So a hard reset and it was running again and the cron log showed when it has stopped, but no errors…

So on the meat of this post. I set about checking to see if livescores had been put in the database.

Starting with a simple Controller on my web api called dbCheck:
This just checks a table I call MethodCallTimes and GetLiveScore as a parameter to retrieve the LastCall, compare it to the current time and send me an email if it was too old. As my Pi updates it every 30 seconds I set the old state to -2 minutes. And now for a snippet of code. So simple with Entity Framework!

internal static bool AreLiveScoresInDatabaseOld()
  apps47_com_dbEntities1 model = new apps47_com_dbEntities1();
  MethodCallTimes times = model.MethodCallTimes.FirstOrDefault(i => i.MethodName == "GetLiveScore");
  if (times.LastCall < DateTime.Now.AddMinutes(-2))
    return true;
  return false;

Now that was set up I had to have some way of pinging this new Controler from somewhere that was not my Pi and not reliant on my home network. Enter my hosting company. I noticed that I should have cronjobs included in my 1 EUR subscription, but I couldn’t for the life of me find out how. So a quick support ticket, and a couple of hours later on a Sunday evening they politely replied and told me where to set it up, which was extremely easy! As in a few dropdowns with explanation and a text field for the URL to ping and I was up and running every 5 minutes. Awesome!!


There was also a little time for new development on Champions League Final. I managed to get the basic database structure ready for the group standings page, which in theory could be used for league standings in the future for other leagues. So time to get this data into the app in a nice way with the team logos. Getting ready and waiting for the final draw.

After the draw yesterday I managed to clean up the design for the group standings and submit this to the dev center… Hope you like it!


Happy Coding!


About markoo

I am a Dad of 4! Husband of 1! Ex-husband of 1! Developer of Windows Phone apps!


No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


Enter your email address to follow this blog and receive notifications of new posts by email.

%d bloggers like this: