The concept of hooks
Table of contents
Set up cron jobs in a project
Cron jobs are hooks (JS callbacks) that are run periodically on the server.
- add a file
hooks/cron.js
to your project - this file should export
async init()
andasync run()
init
will get called once when the project server startsrun
gets called regularly (every second)- you are responsible for the rest!
API for callbacks
The init
and run
callbacks are called with these arguments:
(see project-server.js
for details)
({
...projectApi, // provides .setUserVar, .sendMessage
// see project-api.js
users, // reactive collection of users
messages, // reactive collection of messages
events, // reactive collection of scheduled events
server, // meteor server
projectId // the project Id
})