How can I disable a cron job on PR environment?
Project id: 8eeaf105-a438-44c0-9215-78f268bcf4a9.
8 Replies
Project ID:
8eeaf105-a438-44c0-9215-78f268bcf4a9
[build]
builder = "DOCKERFILE"
dockerfilePath = "./cron/router-stats/Dockerfile"
watchPatterns = ["cron/", "packages/", "!/*.md", "bun.lockb", "package.json"]
[deploy]
cronSchedule = "0 * * * *"
region = "europe-west4"
[environments.pr.deploy]
cronSchedule = "null"
cronSchedule = ""
none works. They both still deploy the service
the service is still going to be deployed, just not as a cron service.
you would also need to overwrite the build and start commands to noop type commands so nothing is ever run
hey Brody! Thanks for your answer could you please give me an example or at least point me to the docs where I can find this?
or is there another way of excluding this service from existing on a PR environment?
it looks like you already know how to use environment overwrites, but here are the docs for them - https://docs.railway.app/reference/config-as-code#setting-environment-overrides
maybe you could base your pr env off of an env that doesnt have the cron services?
I tried doing this:
[build]
builder = "DOCKERFILE"
dockerfilePath = "./cron/router-stats/Dockerfile"
watchPatterns = ["cron/", "packages/", "!/.md", "bun.lockb", "package.json"]
[deploy]
cronSchedule = "0 * * *"
region = "europe-west4"
[environments.pr.deploy]
cronSchedule = ""
startCommand = "echo skipping service execution on PR environments"
This makes the container fail for some reason. Shouldn't it override the startCommand of the Docker entry point command ?
yes it should, why does it fail
but also, did you try my suggestion?
of having multiple environments? I tried it but I don't like it because I will have to constantly maintain that environment as well