Cron Servise Crashing
albertomg098
FREEOP

2 months ago

Hello, for MVP and speed I'm trying to use a ccron service to execute a CLI command (run) for running my ETL processes). Process works as expected, but when finishin deployment, it seems that there must be a way to finish, so Railway service detects it as a succes.

deploy: start command: -> startCommand = "uv run dag_runner --config etl_process --env $ENV"

In my CLI python script:
```
import typer
app = typer.Typer()
@app.command()

def run(
...
) -> None:
## Logic
...
###
sys.exit(exit_code)

if name == "__main__":

app()
```

What am I missing? It works but always crashes once it's done. Thanks for the help!!

$10 Bounty

1 Replies

douefranck
FREE

2 months ago

hey so railway cron jobs are supposed to exit when done, that's normal. two things to check: make sure your exit_code variable is set to 0 for success (anything else shows as crashed), and close all database connections explicitly before exiting , railway docs say unclosed db connections or http sessions will keep your process alive and cause the next cron to get skipped. add db.close() or whatever connection closing you need right before the exit, and ensure exit_code = 0 when your etl finishes successfully

doue


Loading...