Is there a way to get the replica ID from an environment variable or otherwise?
I want to set up a pager to the different replicas of my app server. Was wondering if it's possible to get a replica ID local to the machine and include that in the ping to Uptime Kuma.
16 Replies
Project ID:
29a5fb27-3661-4597-af03-ec799c4720cd
29a5fb27-3661-4597-af03-ec799c4720cd
yes, you're looking for the
RAILWAY_REPLICA_ID
service variableNeat, thank you. Do you know if this stays the same across restart/redeployment or does it change?
link the docs fragly!!
but that variable will change every deployment
See it now. Probably should update the replica docs as well to include a mention to that maybe.
good suggestion
I'm guessing there's no way to route to a specific replica for these health checks, right? Like can I ping via port or something to a specific one?
well what do you want to do exactly? check if all replicas are alive?
Yeah. One of them drops out periodically and it comes back alive but the pager only hits one at a time and bc it's round-robin, it can hit the same ones multiple times.
I'm guessing I need to create a central server that waits for pings from each replica ID and then pings the uptime checker. Was trying to be lazy and not do that.
maybe write a simple inbetween app to do a dns lookup and then ping each ip
example https://utilities.up.railway.app/dns-lookup?value=hello-world.railway.internal&type=ip
my hello-world service is running 5 replicas
value in the url string is the railway domain?
yeah thats the internal domain
of course, this is just an example lookup for the domains AAAA value
Gotcha. Not a problem I can solve today, but this seems like the best move.
kinda sounds like a fun little app to write