7 months ago
Disclaimer: Bit of a noob.
I'm super familiar with running services via docker files.
Am a bit unsure how to run a cron job.
If I have a file in my repo called pull_data.sh in /cron/ dir, how would I have a cron service execute that?
Note: I took a look at documentation on this and am a bit stuck.
0 Replies
7 months ago
yeah docs around this topic are lacking
7 months ago
Create a new service in your existing project
Add any needed variables
Set it up to deploy from the repo that contains the file / script / etc that you want to run
In the service settings, set the start command
the start command will be what's ran on the set scheduleSet the schedule in the service settings
Step 1 and 2 are done. Service created and variables added.
For step 3, I have the repo connected. I take it thats all here.
For step 4, what would the start command be? saying I have the sh file in /cron/.
7 months ago
in your case it would be sh /cron/pull_[data.sh](data.sh)
Also would you recommend it be done via a docker container or is that not necessary here
pull_data.sh runs a python script.
7 months ago
not necessary as runs of the cron job don't rebuild anything
7 months ago
nixpacks should detect that its a python app so you should have python
Gotcha. Quick Q: Without a docker container how would I handle passing in all the dependencies (requirements.txt)
7 months ago
nixpacks handles that
Okay so the cron job worked (so really all is good).
I'm just wondering, should there be things here in the deployments tab?
7 months ago
yes, but that doesnt look like it worked lol
7 months ago
send a link to it please?
7 months ago
the url
7 months ago
correct
7 months ago
only you and team
Seems like the cron part is working. Not sure about the deployment tab though
7 months ago
its running a deploy from 14 mins ago
7 months ago
what about the deploy from 3 mins ago?
7 months ago
from the deploy logs, it looks like you might need to set a root dir
Okay. I start that service trying it with docker file so I just created a new one
7 months ago
^
7 months ago
/ is already the default
7 months ago
have you read the deploy logs?
7 months ago
sorry, i meant build logs
7 months ago
yes there is
7 months ago
yes i can
7 months ago
have you read the logs though?
Sorry I don't want to be missing something but when I look through the build logs, all I see is that screenshot
7 months ago
please read the actual content of the logs, dont worry if they are red or not
I read them. All I see is "
[Region: us-west1]
Using Nixpacks
context: 2b843b44d67edc7bfb5e5c611eba9555
Nixpacks build failed
Nixpacks was unable to generate a build plan for this app.
Please check the documentation for supported languages: https://nixpacks.com
The contents of the app directory are:
.cursorignore
.dockerignore
deploy/
services/
contracts/
v3alts/ setup.py mt5/ shared/ jasper/ admin/ tests/ lib/ .gitignore init.py datasci/
"
7 months ago
^
7 months ago
i feel like you aren't reading the build logs?
7 months ago
where is it located
7 months ago
Nixpacks build failed
Nixpacks was unable to generate a build plan for this app.
I'm just trying to test services/cron/test/run_test.sh
7 months ago
does the script need files from outside of the services folder
7 months ago
thenn your start command should be sh /services/cron/test/run_[test.sh](test.sh)
Let me mess around with this and see if I can fix it. I'm probably just messing up something stupid.
7 months ago
add a nixpacks.toml to the cron folder with this in it -
[phases.setup]
nixPkgs = ['python3']
the set a service variable NIXPACKS_CONFIG_FILE=/services/cron
Hey boss. I tried this nix approach with your nixpacks.toml but was getting a file doesn't exist error.
Out of curiousity, is it not recommended to do it via docker file? I was able to get it work this way but wanted to get your thoughts.
7 months ago
Dockerfile is perfectly fine
Okay great. Does this screenshot look okay? I just wanted to make sure that the deployments are properly closing down after they finish.
I'm scared that they're staying open and every 5 minutes another container is opening up (and charging)
Here's that link in case you need it: https://railway.app/project/92c5e847-f796-4ffc-b29f-0c2a9bc86322/service/1eb1b172-8a40-4084-a91d-8b89360ffa9e/schedule
7 months ago
looks like they are exiting after around 10s according to the time on the right side
But when I open up the log (of one that already completed) it still says active and doesn't say it stopped container or anything like that.
7 months ago
that's fine
7 months ago
correct
7 months ago
no problem!
7 months ago
wdym?
7 months ago
I'm still gonna say no, railway pays me lol
7 months ago
happy to help
7 months ago
!s
Status changed to Solved brody • 7 months ago