2 years 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.
94 Replies
2 years ago
yeah docs around this topic are lacking
2 years 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 schedule
- Set 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/.
2 years ago
in your case it would be sh /cron/pull_data.sh
Also would you recommend it be done via a docker container or is that not necessary here
2 years ago
not necessary as runs of the cron job don't rebuild anything
2 years 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)
2 years 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?

2 years ago
yes, but that doesnt look like it worked lol
2 years ago
send a link to it please?
2 years ago
the url
2 years ago
correct
2 years ago
only you and team
Seems like the cron part is working. Not sure about the deployment tab though
2 years ago
its running a deploy from 14 mins ago
2 years ago
what about the deploy from 3 mins ago?
2 years 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
2 years ago
^
2 years ago
/ is already the default
2 years ago
have you read the deploy logs?
2 years ago
sorry, i meant build logs
2 years ago
yes there is
2 years ago
yes i can
2 years 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
2 years 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/
v3_alts/
setup.py
mt5/
shared/
jasper/
admin/
tests/
lib/
.gitignore
init.py
data_sci/
"
2 years ago
^
2 years ago
i feel like you aren't reading the build logs?
2 years ago
where is it located
2 years ago
Nixpacks build failed
Nixpacks was unable to generate a build plan for this app.2 years ago
does the script need files from outside of the services folder
2 years ago
thenn your start command should be sh /services/cron/test/run_test.sh
Let me mess around with this and see if I can fix it. I'm probably just messing up something stupid.
2 years 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.
2 years 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
2 years 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.

2 years ago
that's fine
2 years ago
correct
2 years ago
no problem!
2 years ago
wdym?
2 years ago
I'm still gonna say no, railway pays me lol
2 years ago
happy to help
2 years ago
!s
Status changed to Solved brody • over 1 year ago

