I have extracted my MySQL-enabled SyncedCron code from one of our projects into a standalone example. I have made it available as a GitHub gist containing 3 files - db.js (database initialization), cron.js (the MySQL-enabled SyncedCron code) and main.js (upon Meteor startup, it creates an example SyncedCron job that prints βTime to wake up!β every day at 7am.
Instructions:
Create a new meteor app with the default settings and replace the files in the server folder with these
meteor create mysqlsyncedcrontest
Put the above 3 files from the gist into the server folder
Install the required Atmosphere and NPM dependencies
meteor add check meteor npm install lodash, mysql2, later
Remove the meteor.mainModule lines from package.json in the root folder.
It is not difficult to modify this code to work with PostgreSQL. These are the primary changes needed:
You will have to manually create the cron_history table in your PostgreSQL database. There is a MySQL table schema definition in the comments at the top of cron.js. You would have to create this table using PostgreSQL syntax and data types.
You will have to modify the code in db.js to work with the node-postgres package instead of mysql2. I had a quick peek. I see that the semantics are very similar.
You may have to tweak the 5 lines of code in cron.js that call qLiveDb() to ensure the SQL is valid for PostgreSQL.