Code works locally, build and deploy succeeds, but ends with server error
Can you please help me?
104 Replies
Project ID:
N/A
N/A
this is the main script that I am running, i am trying to make a crypto screener dashboard
this is the github:
GitHub
GitHub - Vasallius/momo-flask
Contribute to Vasallius/momo-flask development by creating an account on GitHub.
i have tried consulting gpt-4 and have found no success
you wont find any success here either if you cant provide us with any errors lol
ah yes hang on
let me provide some more context
i will just redeploy
since it already crahed
so here is a proof that it does succeed
that is why im a bit confused
do you kind of understand the problem
please don't tag me like that
oh i am sorry
please delete the gunicorn_config.py file
okay okay will do and will push gimme a sec
wait
hold your horses
alright alright
just wanna say that gunicorn_config.py was a chatgpt suggestion thinking i was getting timeout
but i think my script runs fast enough to not get timeout'd
oh wait deploy logs now have something:
that's interesting, im assuming there is a key error because the "data_df" is not filled
delete the port variable in your service variables and instantly cancel the redeploy popup
change line 40 of your main.py back to the original code from line 13 of https://github.com/railwayapp-templates/flask/blob/main/main.py
after this is done we move onto the next error
alright hang on
no rush, just make sure you follow the instructions carefully
did you mean line 147 of test.py
that is what i am running
alright, pushed the changes! redeploying now
remove the start command, start command is defined in the Procfile, so if you want gunicorn to run your test.py file, delete the main.py and rename test.py to main.py and then yes in that case it would be like 147 that you'd need to change
oh okay okay will do
web: gunicorn test:server
is this still the right Procfile
ah nvm u told me to delete
ok ok hang onno, please slow down and listen to what I'm saying
sorry sorry
okay i have followed the instructions
and have deleted and rename test.py to main.py
anything else before i push?
and the port variable is removed from the service?
yup!
and the start command is empty?
yup!
okay, push
gotcha
now you'll probably still run into some errors with panda, but we needed to take care of that stuff before we can get to panda errors
build and deploy succeeded
trying the website now
any panda errors?
metrics are spiking
none but i have this
normally in local my script takes 40 seconds to run (10 threads)
40 seconds is a long time, are you sure it should be taking 40 seconds?
before without multithreading
it takes
3-4 minutes
what are you doing that took 3-4 minutes???
well so to wlak u through the script
there are a lot of cryptocurrency pairs
each pair i api call
to get data
around 100 rows of data
then process that data (add columns) derived from other columns
then get the last 2 rows
then add to a master df
then do calculations on that master df
even so 40 seconds is a long time, I know python isn't known to be the fastest but it's not that slow
but it's a lot of data
like a lot
100 rows?
440 symbols
100 rows each
44000 rows total
then u do calculation on those rows
okay that's a lot
and you are perfectly okay with your app takeing 40 seconds to load?
well normally
i shud bind it to a button
like press button -> wait 40 seconds -> spit out data
well yes, but you'd still have to wait 40 seconds for data to be returned, and as long as your okay with that I can offer a possible solution
yup
40 seconds is good enough
change your Procfile to
gunicorn's default timeout is 30 seconds
ok ok
btw when i run the script locally
this is what it looks like
40 seconds of processing for that lol
yupp
it tells me what assets to buy
carefully filtering over 400 symbols
you're on trail plan?
yess
considering to upgrade ngl if that will fix my issues
well it wasn't even running before, but now that it's running your app might get killed if it tries to use more than 512mb of ram
i get this
sad
any errors in the logs?
key error
just means that data_df wasn't populated
meaning worker stopped before it had the chance to populate the df maybe?
idk
i just dont get why it's so hard to host it remotely when it works perfectly fine on local
dev plan!!!!
though I make no promises
hm is that
5 usd?
no
railway gives you 5$ a month
ah how much is that dev plan then
and you only pay if your usage costs exceed the initial 5$
ohhh
it's based on usage, so if your usage stays under 5$ you can run your services for free
but you are doing heavy compute so again, I make no promises
i will try and check that out
ty for the help
one more thing
is it possible i just run the thing locally
and just use cron or smth
run your python app on your own computer?
Yupp
But people can access the website
you'd need to setup your own web server with the appropriate securities, setup port forwarding on your router, etc
though I can't recommend you open any ports on your own network
Rip ok ok
Nvm ty
no problem
just upgraded
let's see what will happen
yay
congrats
hope this fixes my problem
T_T
hopefully
hmm
get the key error faster
it is possible
when railway runs the app, the api doesn't respond
because the api block the specific location of railway server?
i dont understand the question, sorry
cause like
binance api
sometimes blocks
requests
depending on location
i was wondering maybe that's the case
since my dataframes aren't being populated
oh, then yes
so where is railway server located
check with this
https://utilities.up.railway.app/lookup
sorry how do i use this
read it
i mean i dont know what those are
you dont know your railway domain???
oh
i put my app url there
ok ok
put it in the input box and press the button
yep yep gotcha
so us-west1
is there a way to change that?
and make it asia or smth
there is not
multi region is coming soon
ok ok thank you