Python Cron App (clock process) Procfile help

Does clock process exist in Railway? Like on Heroku: https://devcenter.heroku.com/articles/scheduled-jobs-custom-clock-processes#defining-custom-clock-processes Does it make sence to create Procfile like this
clock: python main.py
clock: python main.py
python app is using schedule (https://github.com/dbader/schedule) module
14 Replies
Percy
Percy2y ago
Project ID: N/A
SHAKA PAKA
SHAKA PAKAOP2y ago
N/A
Ray
Ray2y ago
Not right now, but you can emulate that by having a process for triggering whatever job you want on a schedule. The concept is the same
SHAKA PAKA
SHAKA PAKAOP2y ago
Okay, but I deployed with this Procfile and everything work. I guess "clock:" just does nothing in my case? Will be the same if you write web: python main.py And how actually "python main.py" works if it's Poetry project or does it run it in the poetry shell? And what does it mean in Procfile web:, clock:, etc., I just can see that my app is called "clock" in railway. And in general, does it make sense to write something in the Procfile if I have a poetry application that is using "schedule" module in main.py in root? I'm new to deployments so sorry if these will seem like odd questions. Here: https://docs.railway.app/deploy/builds#procfiles I found info about "web:", but it's not web in my case and I can't find info about other options
Brody
Brody2y ago
web and release are the only real supported procfile directives
SHAKA PAKA
SHAKA PAKAOP2y ago
So what would be correct to specify in my case? .
Brody
Brody2y ago
you would need to do an in code cron scheduler
SHAKA PAKA
SHAKA PAKAOP2y ago
Yep I did it using schedule module But what to specify in Procfile then?
Brody
Brody2y ago
send your current procfile
SHAKA PAKA
SHAKA PAKAOP2y ago
clock: python main.py
clock: python main.py
In terms of code I use poetry, and I have main.py in the project root that run something like this:
import schedule
import time

def job():
print("I'm working...")

schedule.every(10).seconds.do(job)
schedule.every(10).minutes.do(job)
schedule.every().hour.do(job)
schedule.every().day.at("10:30").do(job)
schedule.every(5).to(10).minutes.do(job)
schedule.every().monday.do(job)
schedule.every().wednesday.at("13:15").do(job)
schedule.every().day.at("12:42", "Europe/Amsterdam").do(job)
schedule.every().minute.at(":17").do(job)

def job_with_argument(name):
print(f"I am {name}")

schedule.every(10).seconds.do(job_with_argument, name="Peter")

while True:
schedule.run_pending()
time.sleep(1)
import schedule
import time

def job():
print("I'm working...")

schedule.every(10).seconds.do(job)
schedule.every(10).minutes.do(job)
schedule.every().hour.do(job)
schedule.every().day.at("10:30").do(job)
schedule.every(5).to(10).minutes.do(job)
schedule.every().monday.do(job)
schedule.every().wednesday.at("13:15").do(job)
schedule.every().day.at("12:42", "Europe/Amsterdam").do(job)
schedule.every().minute.at(":17").do(job)

def job_with_argument(name):
print(f"I am {name}")

schedule.every(10).seconds.do(job_with_argument, name="Peter")

while True:
schedule.run_pending()
time.sleep(1)
Brody
Brody2y ago
then just do
worker: python main.py
worker: python main.py
SHAKA PAKA
SHAKA PAKAOP2y ago
is it valid syntax? looks strange
Brody
Brody2y ago
oh sorry
SHAKA PAKA
SHAKA PAKAOP2y ago
thanks
Want results from more Discord servers?
Add your server