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