My use case is deploying redwood as a background job processor. I’m using Faktory based on the example Recipe provided. At development time everything works great, but now I’m trying to figure out deployment, and particularly how to build and deploy the scripts.
The build command only builds
web, but not
yarn rw build
What is the build/packaging/deployment process for scripts?
Are scripts primarily intended for local development use, e.g. seed.js?
Scripts don’t build or get distributed— they are a script very much like a seed script.
You run them via the “exec” command: Command Line Interface | RedwoodJS Docs
As for deployment, they simply live in the directory of your repo that you publish.
Thanks for the response. It’s kind of confusing b/c this example implies a production runtime type use case of triggering background work after a user registers: Creating a Background Worker with Exec and Faktory | RedwoodJS Docs, but there is no way to actually deploy to satisfy a use case like the example?
@viperfx could you help out here with how to deploy a job given you write the how to doc? Thanks.
I currently have a background worker in production and I run the worker in Render. This is just a regular server that installs the packages with yarn and runs the exec command.
The script is run like any node process, so it’s launched with
yarn rw exec faktoryWorker
This will run a long-running process, where the faktory client will continue to listen for jobs from the Faktory server.
I do this on GCP with a modified version of their Rails migrations setup.
Should write a tutorial at some point
The main issue is whatever context you use to run the script needs to be able to see the database
If you use one on the public web it should work in a container with the scripts folder copied in
Thanks, I got it working in Docker with copying in the scripts folder alongside the rest of the api package and building and running with:
yarn rw build api
yarn rw exec my-script
Thanks for the help!
Hey @sdsilas, was able to work up my own Docker image as well, but my image is quite large. I was wondering if you did any optimizations around the build image to minimize bundle size (since most of the code is unnecessary)