R
Railway•13mo ago
Oluwaseun

Environment variables

Hi I've been using railway for one of my api services which works well locally i used go viper to manage environment variables which seems not to work in production below is the screenshot of the error
No description
24 Replies
Percy
Percy•13mo ago
Project ID: N/A
Oluwaseun
OluwaseunOP•13mo ago
N/A
Brody
Brody•13mo ago
on railway you can set service variables https://docs.railway.app/develop/variables#service-variables these variables will be injected into the environment for you, no need for the .env file. it doesn't look like that error has caused you app to hault so you can safely ignore it
Oluwaseun
OluwaseunOP•13mo ago
I already set the variables the issue is that there some service that uses the variables that are not working when in production Which means it's not working
Brody
Brody•13mo ago
if you set the variables in the service variables section they will automatically be injected into the container during runtime, when deployed onto railway you can ignore the missing .env file
it's not working
from your screenshot, i dont see any real errors, i see a fiber start mesage, so it looks fine from my perspective
Oluwaseun
OluwaseunOP•13mo ago
Okay Seems it's now working
Brody
Brody•13mo ago
awesome!
Oluwaseun
OluwaseunOP•13mo ago
Thanks man
Brody
Brody•13mo ago
no prob!
Oluwaseun
OluwaseunOP•13mo ago
the error is still there
No description
Brody
Brody•13mo ago
a panic would be an issue with your code
Oluwaseun
OluwaseunOP•13mo ago
No Everything works fine on my local machine
Brody
Brody•13mo ago
that does not rule out a code issue
Oluwaseun
OluwaseunOP•13mo ago
I don't think so
Brody
Brody•13mo ago
railway isn't telling your code to panic, that's your code panicking, railway runs your code as is
Oluwaseun
OluwaseunOP•13mo ago
okay seems the env variable is not found that's the issue
Brody
Brody•13mo ago
os.Getenv() though a missing env should not cause a panic, seems maybe like improper error handling on your part
Oluwaseun
OluwaseunOP•13mo ago
i'm using viper not os.Getenv
Brody
Brody•13mo ago
im sorry but this wouldnt be an issue with railway, it is an issue with your code
Oluwaseun
OluwaseunOP•13mo ago
can i show you the code??
Brody
Brody•13mo ago
unfortunately these threads are for issues relating to railway, code issues are a bit out of scope, sorry
Oluwaseun
OluwaseunOP•13mo ago
alright
Brody
Brody•13mo ago
though as a fellow go dev.. viper is 🤮 lol
Oluwaseun
OluwaseunOP•13mo ago
might switch back to os.getenv()
Want results from more Discord servers?
Add your server