R
Railway12mo ago
lasse

Redeploy

Hey there, is there away to start a redploy using the Railway API
37 Replies
Percy
Percy12mo ago
Project ID: N/A
lasse
lasse12mo ago
n/a
Brody
Brody12mo ago
yes there is, what's the usecase?
lasse
lasse12mo ago
So the case is i want to redeploy it every 24 hours, if that is allowed
Brody
Brody12mo ago
okay but what's the reason you want to do that
lasse
lasse12mo ago
Better performance for my discord bot.
fedev
fedev12mo 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
lasse12mo ago
Thank you!
Brody
Brody12mo ago
that will not do what they want it won't restart because something will already be running
fedev
fedev12mo ago
But i tried it and it re deployed my service even if it was already running
Brody
Brody12mo ago
did the status say complete?
fedev
fedev12mo ago
It was active and then it removed the previous deployment
Brody
Brody12mo ago
the changelog said they have changed that behaviour to wait for previous deployments to complete
fedev
fedev12mo ago
What do you mean for complete? The is a complete state? Isn't there removed, failed, active, building and initializing ?
Brody
Brody12mo 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
fedev12mo ago
I will try it again to be sure then
Brody
Brody12mo 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
ferret12mo 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
Brody12mo ago
I wasn't gonna open that can of worms
ferret
ferret12mo ago
fair
Brody
Brody12mo ago
I was still curious though
fedev
fedev12mo ago
probably worked for me because the first deployent was from github and then it redeployed from the cron?
Brody
Brody12mo 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
fedev12mo ago
don't understand what you mean for completed but it just redeployed for me I made some screenshots one sec
Brody
Brody12mo 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
fedev12mo ago
mine was in "active" state not "completed"
fedev
fedev12mo ago
Cron was scheaduled to run at minute 30 of every hour
Brody
Brody12mo ago
what kind of app is this
fedev
fedev12mo ago
a websocket server
Brody
Brody12mo ago
interesting and why do you restart that?
fedev
fedev12mo ago
I dont restart it, i was just testing the cron functionality for @lasse
Brody
Brody12mo ago
ah gotcha
lasse
lasse12mo ago
I run into some, its in 500 servers. But dont know with yours
ferret
ferret12mo ago
ah
Brody
Brody12mo 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
lasse12mo ago
It's working
lasse
lasse12mo ago