#Environment Variables

72 messages · Page 1 of 1 (latest)

fossil elm
#

Hello everyone, I'm coming from Digital Ocean, and am very confused as to how to set environment variables. I have an API to deploy that I wrote in Rust. I can get the Dockerfile up and my app deployed using the Railway CLI. I need to set an environment variable called APP_APPLICATION__BASE_URL, which I believe corresponds to RAILWAY_STATIC_URL. Nothing I enter in the "Settings > Variables" page of my deployed app seems to work. In Digital Ocean, you'd get the deployment URL by using ${{APP_URL}}. Any tips would be appreciated.

wraith tapirBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

cloud ploverBOT
#

Project ID: 05c1b2d1-7483-4da5-9ed4-41c5a5e55ba2

fossil elm
#

I don't see a project ID, but the service ID is 05c1b2d1-7483-4da5-9ed4-41c5a5e55ba2

stuck meadow
#

may I ask what's wrong with grabbing the url from RAILWAY_STATIC_URL?

#

maybe I should mention that this variable is set automatically, there's nothing you need to do for that variable to exist, this may give you a better idea of what's going on with variables in the container
https://utilities.up.railway.app/env-vars

fossil elm
#

If I specify a key value pair, APP_APPLICATION__BASE_URL (which is the format my code wants) and make that correspond to RAILWAY_STATIC_URL, the health check fails, presumably because the /health_check endpoint is not reachable.

stuck meadow
#

oh I take it you do not want to change that environment variables name?

fossil elm
#

No, no, just trying to understand how to use it correctly.

mental pumice
fossil elm
#

Yep, found that and read through it.

mental pumice
#

In your case, the healthcheck endpoint doesn't need to know the root of your app, you just point it to the route that you expect to return 200

#

if you wanna remap a var you can do something like

fossil elm
#

Right, which is /health_check...I entered that in the settings.

mental pumice
#

APP_APPLICATION__BASE_URL and set that to ${{ RAILWAY_STATIC_URL }}

#

You need to template the string

fossil elm
#

Got it...trying again.

mental pumice
#

for the record, this value shouldn't affect healthchecks, so curious to see your config there

fossil elm
#

App didn't need a rebuild, but I'm still getting a failed health check. Maybe I've entered the endpoint wrong.

stuck meadow
#

do you have an endpoint registered at that endpoint?

#

(yes I am bad at English)

mental pumice
#

are you serving from /health_check?

fossil elm
#

I think so? If I run the app in dev, and go to that endpoint it returns a 200 OK with no body.

mental pumice
#

remove the slash at the start?

fossil elm
#

I'm serving a simple page with a login button from the / route.

mental pumice
stuck meadow
#

okay million dollar question, what host and what port is your app currently running on?

fossil elm
mental pumice
#

me first

mental pumice
#

Can you give me a link to your application?

fossil elm
#

Still failing

mental pumice
#

Doing so means I can check your project

fossil elm
#

crusty-rustacean-api-production.up.railway.app

#

Should add that I used the Railway CLI to deploy my docker file.

mental pumice
#

just your project url

#

(can you believe I can't easily search via url?)

#

the project ID you gave me doesn't lead anywhere 😢

mental pumice
#

oh wow

#

I can look that up

#

one sec

#

Going to remove the healthcheck- my guess here is that you aren't serving at root...

stuck meadow
#

I like my guess better

mental pumice
#

Jeff, your app builds properly, are you listening on 0.0.0.0?

fossil elm
#

Checking...

#

Looking at the spec.yaml for Digital Ocean, which is irrelevant I know, the app should be using 8000...I'm not sure I specified that anywhere when I deployed via the Railway CLI. Just logged in, did init, then link, then up.

mental pumice
#

That can help!

#

Adding a PORT var

stuck meadow
#

then you'd need to tell railway what port your app is listening on, set a PORT variable to 8000

fossil elm
#

Ok, that must be what I'm missing then. Will look that up in the docs.

mental pumice
#

oh wow

#

logs is showing your app is panicking on request

#

when you visit root- something must be happening

#

it seems like it's expecting redis?

fossil elm
#

Ok, that's better! I need to finish the rest of the config then.

mental pumice
#

(also sorry for looking at your logs- just wanna help you out here)

fossil elm
#

How did you get those logs? If I'd been able to see that I wouldn't have wasted your time.

#

No worries at all, looking at the logs, it was very helpful.

mental pumice
#

Clicking the service

#

Opens the logs view

#

(Not a waste, I learn a lot of from these interactions. Still a lot we can do in terms of education)

fossil elm
#

🙂 Noobie noobs like me must drive you guys crazy.

mental pumice
#

Only Brody

fossil elm
#

Anyways, thanks so much, the PORT is up there now, and you've helped me out tremendously.

#

BTW, love that the Railway CLI is written in Rust 🙂