Forum BigDB Workaround to do cronjobs using PlayerIO's framework

Discussion and help relating to the PlayerIO database solution, BigDB.

Workaround to do cronjobs using PlayerIO's framework

Postby lutc » April 11th, 2013, 12:29 pm

Has anyone figured out a workaround to do cronjobs using PlayerIO's framework yet?

I was thinking of using multiplayer code and a nextUpdate value stored in bigDB to do the work but I don't see a way for us to be certain that the multiplayer code will be running at that exact moment that I want the cron job to run.

Furthermore if there are multiple rooms running the same multiplayer code, there's going to be a race condition and/or the cronjob might be executed multiple times.

One alternative is to trigger it manually, but that defeats the purpose of having a cronjob.

Anyone has a good alternative?
lutc
 
Posts: 64
Joined: February 13th, 2013, 3:05 pm

Re: Workaround to do cronjobs using PlayerIO's framework

Postby lutc » April 16th, 2013, 9:22 am

FYI, to solve the issue where multiple rooms are running the same multiplayer code causing a race condition, what I am doing is to update the nextUpdate value at the start of the cron job and save using optimistic locking, and only begin running the cron job proper when the save is successful since optimistic locking will only allow one instance of the object to be saved.

This method seems to work so far, provided that you have at least 1 player online every cron period.
lutc
 
Posts: 64
Joined: February 13th, 2013, 3:05 pm


Return to BigDB