kill previous deployment before starting a new one?
Hello, I think I have an issue because "the old" deployment remains active until the next one is "up", and because of that when the new ones starts to init there's some services that don't start because they are already running (on the old deployment) and then when the old deployment goes off, they never get started because the "new one" already executed the "init" command.
Does anyone knows how to "force" a deployment to be stopped at the same time of the new deployment starts?
Thanks.
47 Replies
Project ID:
839f9760-85d5-4e76-960d-bec6ed29aafb
839f9760-85d5-4e76-960d-bec6ed29aafb
idk if there's a setting for that but last resort you can just add a volume, railway will make sure your previous deploy stops before a new one start at the moment when your service has a volume connected
there is a setting for that
oh neat
set
RAILWAY_DEPLOYMENT_OVERLAP_SECONDS
to 0
in dockerfile or railway.toml?
env probably
service variables
ok
what's the difference between service variables and env?
good question, I want to know the difference as well
as I don't know if I'm duplicating variables
env is too broad of a term
cause I have some in ENV and again in service
oh okay
env var* <:chad_gamer:1000044370411663370>
still too broad
what that means?
too broad?
dictionary.com
Ok let me ask it this way. If I want to pass a VARIABLE to dockerfile, what is best. To add a variable on the service and then pass the ARG to dockerfile or by just adding the variable on the service that will automatically be passed to dockerfile even if I don't "ARG" and declare it?
depends
does this variable need to be used at build time?
yes
then you add it as a service variable and reference it with ARG (you don't need ENV)
all service variables are available as build args, and you only need to explicitly reference the variables you need during build, when your app starts all services variables are automatically available (hence not needing ENV)
notice the lack of ENV https://docs.railway.app/deploy/dockerfiles#environment-variables
I see
Okay, thanks for the useful info.
I'm going to test the variable RAILWAY_DEPLOYMENT_OVERLAP_SECONDS
I assume this is a bot? where two instances of the bot can't run with the same token at the same time?
actually a webhook. It starts a webhook listener event for a fixed address: example.com/123456/webhook/
but it can't start it if already running on the old one
makes sense
two discord bots can actually run on the same token surprisingly
(telegram bots can't)
discord bots built different 💪
still both of them up
should I add the ARG on dockerfile?
no, it's a variable needed by railway, not your code
both are not up, one is still deploying, as soon as that one finishes deploying the old active deployment is removed instantly (0 seconds)
make it
-20
don't actually, doubt that'll work )it doesn't values are clamped
smth
still doesn't work
so if I manually stop the current deployment
show me the variable
and I start a new one it works
but if I re-deploy then it doesn't
looks good
the dashboard may not update super fast, but with that you should not have two deployments running at the same time
you'll still see a build and deploy happen while there is already an active deployment, but as soon as the new deploy finishes the old one is killed
thats the problem
when the new finishes the old is killed
I want it as soon as the "new starting" to deploy it kills the other
not when finishes
why though
cause the way it is now, it doesn't work 😆
If I manually "reproduce" the stop one and start a new one
it works
sorry but there's something else wrong with your setup, setting that variable to zero makes it so that only one active deployment is running at any given time
having an in progress build does not effect anything as no traffic is swapped over until the in progress build finishes
ok
if there was an option to have the previous deployment killed before a new deployment even starts, that would cause massive downtime
so yeah there's something else wrong with your setup/code/something