Auto increment variable?
is it possible to set variables to auto increment based on the replicas spawned? i.e, I have a variable cluster set to 1 but if another replica is added that increases to 2
Solution:Jump to solution
each replica would get a unique
RAILWAY_REPLICA_ID
environment variable available to it, its a UUID not an Int but it sounds like it should work for your usecase10 Replies
Project ID:
N/A
N/A
there isnt a way to do that natively through the dashboard, but would you mind telling us your usecase?
it's a discord bot, and I was kinda hoping I can set this up natively without explicitly doing so myself. I'm spawning multiple instances of the bot and I use the cluster variable to identify them accordingly for logs.
but then again, does railway already do this in a way when u spawn replicas? i.e, having an identifier for them that I can use within my code instead?
Solution
each replica would get a unique
RAILWAY_REPLICA_ID
environment variable available to it, its a UUID not an Int but it sounds like it should work for your usecaserailway also already adds on the replica id to the logs
and I can just access just access the .env from within the code right?
yep it's just a regular environment variable
gotcha, thanks!
another question for you, I have some logic that more or less sets shards to a specific cluster. got any idea on how using the replica id I could do such thing as the replica IDs aren't exaclty single digits or incremental.
nvm, got it. again, thank for the help!
share your solution!