Cron job deployment logs not showing up
razvanparaschiv
PROOP

2 years ago

Project id: 8eeaf105-a438-44c0-9215-78f268bcf4a9.

I am trunning to run a cron job that has the configuration set in a railway.toml file

I have configured it so that it run from a docker file. If I build the image and run it locally everything works as expected.

Yet, when I deploy it on Railway, the cron services shows that it is about to run in x minutes but, aside from successfully building the Docker image, there are no deploy logs. How I translate that is that the container is not run in the first place.

Closed

51 Replies

razvanparaschiv
PROOP

2 years ago

Hello @Brody ! Do you reckon there might be something that I might've misconfigured? If it's the case for a bug is there a workaround for it?


2 years ago

please do not tag team or mods - <#727685388893945877> #5


2 years ago

anyway, what makes you say the container isn't being ran?


razvanparaschiv
PROOP

2 years ago

Thank you for your response. The fact that it is not displaying anything in the Deploy logs section. yet, it should since it thoretcally "has been run"


drmarshall
PRO

2 years ago

+1 – I am seeing the same. I waited up to an hour in the event there was some queue delay.

I see several posts that seem to suggest crons have stopped working or there is a behavior change: https://help.railway.app/feedback/cron-reliability-improvements-c2f2c959


2 years ago

im not seeing any cron services in any of your environments?


razvanparaschiv
PROOP

2 years ago

Um, I think there should be. development-testnet environment Cron Jobs group. I think service id of one of the cron jobs is: 17c81b48-6409-4b66-ba85-5537f35e62aa


razvanparaschiv
PROOP

2 years ago

1281564108029952102


razvanparaschiv
PROOP

2 years ago

1281565996368269312


razvanparaschiv
PROOP

2 years ago

builder = "DOCKERFILE"
dockerfilePath = "./cron//Dockerfile"
watchPatterns = ["cron/**", "packages/**", "!/*.md", "package.json"]

[deploy]
cronSchedule = "0 0 * * *"
region = "europe-west4"```


2 years ago

I must be blind then, my bad, I'll give another look


razvanparaschiv
PROOP

2 years ago

Please, it would be really helpful. Maybe there is something misconfigured on our end


2 years ago

I'll look when I'm back at my computer <:salute:1137099685417451530>


2 years ago

but in the mean time, please tell me more about this cron job.

language?

what does it achieve?

are you using a logger library?

etc


2 years ago

update, found the service, something really strange is going on here for sure


razvanparaschiv
PROOP

2 years ago

Great news. The service is trying to run a Dockerfile that runs a binary file created after bun env build action. Other than that it is pretty standard. Locally (on my machine Macbook M1 series) everything works fine. For some reason on the Railway env nothing works


razvanparaschiv
PROOP

2 years ago

1282629787717992458


razvanparaschiv
PROOP

2 years ago

Language is Typescript

Run time environment is bun.js

logger is used everywhere in our project so I doubt it's the case, we use pino

The railway.toml is provided above. Here is the Dockerfile:

FROM node:20.12.2 AS build

RUN npm install -g bun@1.1.26
WORKDIR /app
COPY . .
RUN bun install --frozen-lockfile --prefer-offline

ARG TURBO_TEAM
ENV TURBO_TEAM=$TURBO_TEAM
ARG TURBO_TOKEN
ENV TURBO_TOKEN=$TURBO_TOKEN
RUN bun turbo build --filter secret-cron-name

FROM gcr.io/distroless/base-debian11
WORKDIR /app
COPY --from=build /app/cron/secret-cron-name/bin /app/bin

CMD [ "/app/bin" ]```


2 years ago

what are your logging settings? are you logging unbuffered to stdout / stderr?


razvanparaschiv
PROOP

2 years ago

Yes. It worked for a couple of days, now they are not being run again. Seems like the cron jobs are very unreliable


2 years ago

are you sure your application is exiting after it's done it's task?


razvanparaschiv
PROOP

2 years ago

Yes, it even has a process.exit(0) at the end


razvanparaschiv
PROOP

2 years ago

when testing locally, it always ends


2 years ago

how long does it take?


razvanparaschiv
PROOP

2 years ago

1 should take under 30 seconds. The other should probably take 5 minutes initially. Aftewards it will take under 30 seconds as well


2 years ago

what is your cron schedule


razvanparaschiv
PROOP

2 years ago

0 * * * *


razvanparaschiv
PROOP

2 years ago

For example, this is the cron service that does not run: b734ede7-3e09-4b94-8699-28d74a046e30


2 years ago

okay so every hour right?


razvanparaschiv
PROOP

2 years ago

yes


razvanparaschiv
PROOP

2 years ago

tried running it manually and it still does not log anything


2 years ago

what logging library are you using?


razvanparaschiv
PROOP

2 years ago


2 years ago

are you the same person who reported that railway was overwriting the log level?


razvanparaschiv
PROOP

2 years ago

No, this is the only thread I have opened


2 years ago

okay, thank you.

do you have a custom transport?


razvanparaschiv
PROOP

2 years ago

No, standard stdout/stderr


2 years ago

I'm fairly confident Pino is buffering logs, if Pino is buffering logs railway can't pick the logs up to send to the frontend


razvanparaschiv
PROOP

2 years ago

We are using pino for all of the services. They all log perfectly fine. The only service instances that don't print out the logs are the crons. Moreover, some of them should surely not fail, but I can't see their effects. This leads me to thinking that the cron jobs are not run in the first place


2 years ago

does railway's UI show you that your job was ran?


2 years ago

or does it say skipped?


razvanparaschiv
PROOP

2 years ago

1285249826056962099


2 years ago

can you enable the beta cron UI in the service settings


razvanparaschiv
PROOP

2 years ago

Yes, I will attach a video in a bit


razvanparaschiv
PROOP

2 years ago

Actually, it would take too much to record a video. I will summarize it. Pressing on run now, redeploys the cron job

Nothing else shows up. I will send you a screenshot in 3 minutes when the previous deployment shows that's supposed to run

1285253191046533121

1285253191381946490

1285253191667028090

1285253192137052334


2 years ago

can you try duplicating the service? (right click -> duplicate)


razvanparaschiv
PROOP

2 years ago

It should have ran but it didn't

1285254156382109727

1285254156789219441


razvanparaschiv
PROOP

2 years ago

Done, duplicating it


2 years ago

in our backend we have this marked as completed


razvanparaschiv
PROOP

2 years ago

There's definitely something wrong. I am using this kind of dockerfile


razvanparaschiv
PROOP

2 years ago

so probably you only mark this as completed because its being built?


Welcome!

Sign in to your Railway account to join the conversation.

Loading...