R
Railway•8mo ago
ENT3I <3

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.
No description
47 Replies
Percy
Percy•8mo ago
Project ID: 839f9760-85d5-4e76-960d-bec6ed29aafb
ENT3I <3
ENT3I <3•8mo ago
839f9760-85d5-4e76-960d-bec6ed29aafb
Fragly
Fragly•8mo ago
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
Brody
Brody•8mo ago
there is a setting for that
Fragly
Fragly•8mo ago
oh neat
Brody
Brody•8mo ago
set RAILWAY_DEPLOYMENT_OVERLAP_SECONDS to 0
ENT3I <3
ENT3I <3•8mo ago
in dockerfile or railway.toml?
Fragly
Fragly•8mo ago
env probably
Brody
Brody•8mo ago
service variables
ENT3I <3
ENT3I <3•8mo ago
ok
Fragly
Fragly•8mo ago
what's the difference between service variables and env?
ENT3I <3
ENT3I <3•8mo ago
good question, I want to know the difference as well as I don't know if I'm duplicating variables
Brody
Brody•8mo ago
env is too broad of a term
ENT3I <3
ENT3I <3•8mo ago
cause I have some in ENV and again in service
Fragly
Fragly•8mo ago
oh okay env var* <:chad_gamer:1000044370411663370>
Brody
Brody•8mo ago
still too broad
Fragly
Fragly•8mo ago
whyy
ENT3I <3
ENT3I <3•8mo ago
what that means? too broad?
Brody
Brody•8mo ago
dictionary.com
ENT3I <3
ENT3I <3•8mo ago
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?
Brody
Brody•8mo ago
depends does this variable need to be used at build time?
ENT3I <3
ENT3I <3•8mo ago
yes
Brody
Brody•8mo ago
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
ENT3I <3
ENT3I <3•8mo ago
I see Okay, thanks for the useful info. I'm going to test the variable RAILWAY_DEPLOYMENT_OVERLAP_SECONDS
Brody
Brody•8mo ago
I assume this is a bot? where two instances of the bot can't run with the same token at the same time?
ENT3I <3
ENT3I <3•8mo ago
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
Brody
Brody•8mo ago
makes sense
Fragly
Fragly•8mo ago
two discord bots can actually run on the same token surprisingly
Brody
Brody•8mo ago
(telegram bots can't)
ENT3I <3
ENT3I <3•8mo ago
No description
Fragly
Fragly•8mo ago
discord bots built different 💪
ENT3I <3
ENT3I <3•8mo ago
No description
ENT3I <3
ENT3I <3•8mo ago
still both of them up should I add the ARG on dockerfile?
Brody
Brody•8mo ago
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)
Fragly
Fragly•8mo ago
make it -20 Trollface don't actually, doubt that'll work )
Brody
Brody•8mo ago
it doesn't values are clamped
ENT3I <3
ENT3I <3•8mo ago
smth still doesn't work so if I manually stop the current deployment
Brody
Brody•8mo ago
show me the variable
ENT3I <3
ENT3I <3•8mo ago
and I start a new one it works but if I re-deploy then it doesn't
ENT3I <3
ENT3I <3•8mo ago
No description
Brody
Brody•8mo ago
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
ENT3I <3
ENT3I <3•8mo ago
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
Brody
Brody•8mo ago
why though
ENT3I <3
ENT3I <3•8mo ago
cause the way it is now, it doesn't work 😆 If I manually "reproduce" the stop one and start a new one it works
Brody
Brody•8mo ago
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
ENT3I <3
ENT3I <3•8mo ago
ok
Brody
Brody•8mo ago
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