R
Railway15mo ago
lasse

Redeploy

Hey there, is there away to start a redploy using the Railway API
37 Replies
Percy
Percy15mo ago
Project ID: N/A
lasse
lasse15mo ago
n/a
Brody
Brody15mo ago
yes there is, what's the usecase?
lasse
lasse15mo ago
So the case is i want to redeploy it every 24 hours, if that is allowed
Brody
Brody15mo ago
okay but what's the reason you want to do that
lasse
lasse15mo ago
Better performance for my discord bot.
fedev
fedev15mo ago
Railway has a built in cron service redeployer Service => settings => chron schedule
0 0 * * *
0 0 * * *
this should redeploy your service every day at 12AM
lasse
lasse15mo ago
Thank you!
Brody
Brody15mo ago
that will not do what they want it won't restart because something will already be running
fedev
fedev15mo ago
But i tried it and it re deployed my service even if it was already running
Brody
Brody15mo ago
did the status say complete?
fedev
fedev15mo ago
It was active and then it removed the previous deployment
Brody
Brody15mo ago
the changelog said they have changed that behaviour to wait for previous deployments to complete
fedev
fedev15mo ago
What do you mean for complete? The is a complete state? Isn't there removed, failed, active, building and initializing ?
Brody
Brody15mo ago
you missed deploying and complete railways cron scheduler will skip a schedule if there is already a deployment in the active state, at least according to their changelog prom the previous week
fedev
fedev15mo ago
I will try it again to be sure then
Brody
Brody15mo ago
https://railway.app/changelog/2023-08-11-cron-jobs-generally-available
We now skip job execution if a previous cron is still running
assuming that's true, you would not be able to use cron to restart a discord bot because it would be running when the next job starts, thus getting skipped
ferret
ferret15mo ago
i'm just wondering why you would need to restart it. i run probably 10+ discord bots on railway with no performance issues over time
Brody
Brody15mo ago
I wasn't gonna open that can of worms
ferret
ferret15mo ago
fair
Brody
Brody15mo ago
I was still curious though
fedev
fedev15mo ago
probably worked for me because the first deployent was from github and then it redeployed from the cron?
Brody
Brody15mo ago
no that wouldn't be the case if you are right and the cron did stop execution of your previously active state deployment then that is a bug unless you are confusing active with completed
fedev
fedev15mo ago
don't understand what you mean for completed but it just redeployed for me I made some screenshots one sec
Brody
Brody15mo ago
deployments can have many states, one of which would be "completed" this state is for when your app exits with a non error code, and according to the changelog a cron schedule would be skipped if your deployment is not in this state when the schedule is going to run
fedev
fedev15mo ago
mine was in "active" state not "completed"
fedev
fedev15mo ago
Cron was scheaduled to run at minute 30 of every hour
Brody
Brody15mo ago
what kind of app is this
fedev
fedev15mo ago
a websocket server
Brody
Brody15mo ago
interesting and why do you restart that?
fedev
fedev15mo ago
I dont restart it, i was just testing the cron functionality for @lasse
Brody
Brody15mo ago
ah gotcha
lasse
lasse15mo ago
I run into some, its in 500 servers. But dont know with yours
ferret
ferret15mo ago
ah
Brody
Brody15mo ago
okay well obviously the best solution would be to fix the performance issues, if that's out of the question, try railways cron, if that doesn't do it, I have another solution that uses the railway api to restart your service in the form of a template
lasse
lasse15mo ago
It's working
lasse
lasse15mo ago
Want results from more Discord servers?
Add your server