Unique variables for replicas
duhby
HOBBYOP

2 years ago

How can I assign a different token environment variable to each replica? Or have the replicas choose from a list of them in one env var or something

9 Replies

duhby
HOBBYOP

2 years ago

N/A


2 years ago

There is no way to manually provide a specific variable per replica but each replica will get a unique RAILWAY_REPLICA_ID variable -

https://docs.railway.app/reference/variables#railway-provided-variables


duhby
HOBBYOP

2 years ago

Hm alright, I'll do some testing


2 years ago

mind sharing your usecase?


duhby
HOBBYOP

2 years ago

Basically I have worker bots that get sent requests through rabbitmq to process, and each one has a different api token it uses


duhby
HOBBYOP

2 years ago

It could probably be done without replicas and just in one script, but it's nice having rabbitmq deal with distribution and a few other things


2 years ago

ah cool, was RAILWAY_REPLICA_ID sufficient to get that up and working?


duhby
HOBBYOP

2 years ago

since the replica ids change every time the project changes, I don't really see a way it can be used with that, but I figured out that I can distribute the api tokens using a semaphore system with rabbitmq


2 years ago

makes sense


Loading...