Running Python Script on Railway
I have a python script that:
- gets that from api
- do data analysis
- insert into database
The code runs continously with a while True: statement. Is it possible to run this code on railway ? How could I do that?
Image contains the final part of the code
42 Replies
Project ID:
eda27a88-d8f4-495f-b917-1fd2269f5764
Project ID: eda27a88-d8f4-495f-b917-1fd2269f5764
https://nixpacks.com/docs/providers/python
Python is detected if any of the following files are found
- main.py
- requirements.txt
- pyproject.toml
- Pipfile
so if you have a main.py file it will be ran
if you have a requirements.txt/pyproject.toml/Pipfile the dependencies will be installed
if you want this ran constantly
what brody said just make a requirements.txt with all your dependancies like asyncio and then just make a .toml or a procfile
i usually just make proc
which since yours isnt a webserver
could just go on a worker
worker: python main:app
i think thats correct
not at my pc rn
^
railway.json/toml is the preferred method for new projects
omg guys,tks
tks for the support
It makes sense
you guys are awesome
for clarity, if your .py file is main.py, you dont need a procfile or railway.json/toml since railway will automatically run a main.py
Only the requirements.txt and pipfile
it was requirements.txt or pyproject.toml or Pipfile
you only need one of them, you should only have one of them
only main.py and requirements.txt
i didnt know u didnt need proc thanks brody
^ you know how a requirements.txt is formatted im sure yeah?
only if your py file is main.py
https://nixpacks.com/docs/providers/python#start
awesome, i'm really impressed you are not in railway staff brody.
haha thanks
dont worry bro imma move mountains to get railway to recruit him
get dis man da credit he deserve
and morpheus, thanks for your awesome help aswell
anytime bro
awesome stuff here
ā¤ļø
python code is my domain so if you need help let me know
my regards from brazil
thanks!!
tamo junto!
whatever he said š
i read part of it
but not all
Morpheus, you are a Algo Trader, thats awesome! You guys are helping me build a crypto indicator company. In the future maybe you can access our API to develop some of your strategies
we have several public api's accessible
top 250 crypto coins on a 1 min interval
all fx pairs with realtime
all popular cash & future indicies
roughly 560 instruments in total
I provide indicators like hyblock, glassnode and cryptoquant
i dont know any of them
we have our own libraries
for market structure for example
chochs etc
Awesome man
I really appreciate your work
i believe we own the most accurate one wait i show u
awesome
In a good moment for you, could you send me some resources to start in algo trading?
check your dm
these 2 libs are for ms and liq
wowww thats awesome!
guys, do you think its good to run this code 24h/7 in production?
do you need it to run 24/7?
railways running costs are incredibly low so it doesnt really matter
My code updates a database each 5 minutes, but when its not updating, its sleeping.
is there any specific reason you want a 5 min interval into a database?
by storing it into a db straight away im assuming you will collect it to use it another time
but not in that instance right ?
With the database being updated in database, my Dash Plotly application creates a chart using the database data. So I' thought it would be good to always updated the data in db so my user can always check upadted data.
Ah !!!!
What you can do instead is send a batch get request whenever the user loads the chart, and everytime they batch request you cache that
Thats what we do
So fetch the equivalent amount as amount of bars that your chart populates obv
That makes sense
No need to database here right
nope
unless you want to cache it to reduce request size if you have more than 1 end user using it
but if you arent rate limited, i would just make the requests as candlestick data is not alot
Even tought my db is updating, my chart isnt. I'm using a Dash app with mongodb and redis cache
I believe the problem is with dash