guys why do railway return `Application failed to respond` whenever im trying to access my app
here is my code
55 Replies
Project ID:
N/A
make sure you listen on the PORT railway provides
take a look at this: https://docs.railway.app/guides/fixing-common-errors
hello, thanks for rapid answerm where i can get the port provided by railway?
it's an environment variable
its empty 😦
It's not stated there by default, it's a railway provided variable
learn more here: https://docs.railway.app/guides/variables#railway-provided-variables
ok, i guess it is 7981
yes fragly that would work, but it's not the proper solution
it changes between deployments
oh ok
@lplpqq please use gunicorn in your start command https://docs.railway.app/guides/fixing-common-errors#python--gunicorn
how can i replace webapp.ru with uvicorn here
sorry my mistake, I meant gunicorn
actually that doesnt matter they are similar
it does matter
you'd want a Procfile similar to this https://github.com/railwayapp-templates/flask/blob/main/Procfile
but i dont know how to replace gunicorn in my case
just make
app
variable global and remove main functio?app is already global, you should not need to touch the code you showed
Thanks!!! that worked, port is different on each deploy, right?
yes
fragly ðŸ˜
<:e_guh:1114526512339763341>
am I wrong?
you helped them run a development server
i didnt get you, its local, isnt that right?
from the code you showed me, app is a global variable
im talking about this code
wdym brody ðŸ˜
then yes make app global
aight, just a moment
you need to use gunicorn too
does it work with gunicorn?
wait, but now i need to fill railway.json file, right?
yes, or a procfile, up to you
gunicorn __main__:app
is this the full startCommand
?try it, trying is a good way of learning
hypercorn main:app --bind "[::]:$PORT"
this is command from fastapi template
are you using fastapi?
no, but it is from fastapi template
right but you arent using fastapi
yeah, but i guess commands are the same
i would check instead of assuming
i know, i know
guys, bot was working the second ago
but now log says
/bin/bash: line 1: gunicorn: command not found
aahhh
i need to put it into requirements,txt
aight, ive done, its building...
deploying
Failed to find attribute 'app' in 'main'.i'd strongly recommend you familiarize yourself with aiohttp and gunicorn
ok, thanks, but how am i supposed to fix that
familiarize yourself with the technologies you are using, we unfortunately cant offer code help
i fixed this issue, now no errors in log, but my bot doesnt respond
my bot doesnt respondgoing to need more info than that
guys, it works great if i just replace config.app_port with os.getenv('PORT'), but why this way is discouraged?
that starts a development server
also that doesnt require any changes in railway.json file
that is what?
it uses more resources and thus will cost you more to run on railway
wait, what uses more resources
over
?
running your app in development mode will use the most resources
development mode is when i start the script using command in railway.json file?
alright guys, thanks for help, i gotta go right now, but i will reach out again very soon, because i havent managed to start the bot