How do I run background or cron jobs?

So graphile-worker seems to work great.

I had to create a new script in redwood and now I can start an additional docker container with rw exec worker to run that worker.

image

Also needed to copy the scripts folder, which I didn’t do before
image

My worker.ts looks like this:

Implementing the tasks is pretty straight forward and I seem to be able to use services and database stuff without a problem.

Things I’m not happy with, but seem non breaking:

  1. Importing stuff to a task in the script folder seems weird. As vscode doesn’t seem to figure out automatically, where to import stuff from.
  2. I’m not fully sure, where packages get pulled from. It seems to work fine to import them in the package.json in the api folder. But it seems a bit out of control, it would be nice, if the scripts folder had it’s own package.json
2 Likes