R
Railway11mo ago
lasse

Redeploy

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