Sending http requests to new service
hey - I just deployed a service on railway & added a custom domain, from the deploy logs it looks like the application process is starting on & listening on
0.0.0.0:{PORT}
(following https://docs.railway.app/deploy/exposing-your-app, using the railway provided env port for PORT
. But sending external requests to the service on the /status
health endpoint (that just returns a 200
status code and { "message": "OK" }
does not work.
There's a lot of in-between stuff that I'm wondering on - if I send a HTTP request to https://{HOST}/status
I imagine that the request goes to port 443
then railway forwards that internally to the internal PORT
...so my application should be picking it up. Everything works fine locally, just have this last small thing to work out on how packets are getting routed. ThanksSolution:Jump to solution
swap to a foreground process, you generally want that when in a docker container anyway
28 Replies
Project ID:
8f12a5b5-c874-4220-8712-b3709fa9bc73
project id:
8f12a5b5-c874-4220-8712-b3709fa9bc73
I wonder if there is a way I can enter a virtual shell to see what's going on
but ik that the application is living in abstraction-world & maybe not possible to shell into anywhere
maybe I need to give the
PORT
env variable a concrete value & proxy? (https://docs.railway.app/deploy/exposing-your-app#tcp-proxying)
(or maybe I need to map 443
-> to a concrete PORT
value)
But I imagine the above isn't necessary - probably something im missingis this just a plain http (not https) server?
plain http
accepts http 1.1?
not sure - checking
looks like it does
curl -I --http1.1 localhost:8080
HTTP/1.1 404 Not Found
date: Thu, 09 Nov 2023 21:20:04 GMT
server: uvicorn
content-type: text/plain
curl -I --http1.1 https://{...host-redacted...}/status
HTTP/1.1 503 Service Unavailable
content-type: text/html
x-railway-fallback: true
content-length: 2942
date: Thu, 09 Nov 2023 21:20:33 GMT
server: railwayoh this is a uvicorn app?
locally runs
uvicorn
let me grab listen()
on railway, are you starting uvicorn from within your code or from the command line?
railway will run
python3 main.py
which triggers the above - all env variables resolve fine (Environment
is a wrapper class where I do some processing)background progress, maybe your app is exiting right after it starts
hmmm
good point
Solution
swap to a foreground process, you generally want that when in a docker container anyway
does the driver process of railway expect a foreground process to keep the driver alive?
noted.
I imagine Railway is running a driver process spawning the child, and it is just seeing the child exit
railway is just docker containers, there's nothing super special going on
i see
so is the container shutting down?
I'm less familiar with docker (hands-on)
what's the status of the deployment?
failed
(btw working on switching to foreground running)oh well yeah lol forgot about the healthcheck haha
let me know how that goes!
sure - will update.
ok - back, still refactoring (grabbed food)
looks like we're good running in the foreground
awsome, glad you could solve this!