R
Railway

✋|help

Docker Service CRON Restart?

AAyush8/20/2023
Hi guys, i have a single docker service running. I'd like to restart this service periodically via the Railway CRON functionality. Is this achivable? I am not too sure how to get my container_id
0 0 * * * docker restart <container_name_or_id>
0 0 * * * docker restart <container_name_or_id>
PPercy8/20/2023
Project ID: N/A
AAyush8/20/2023
N/A
AAdam8/20/2023
Unfortunately that’s not what Railway’s cron jobs are built for. What you can do though is set up a function in your code that quits your program according to a cron schedule and set your service to restart after quitting in Railway settings
BBrody8/20/2023
I've made a template for the exact functionality you would like, but it's not quite ready for public release, would you like me to share it when it's ready?
AAyush8/21/2023
@Brody that would be awesome thank you very much!
BBrody8/21/2023
so just to be clear, you just wanna restart your service on a cron schedule? just the same as clicking the 3 dot menu on the deployment and clicking restart?
AAyush8/21/2023
@Brody Correct
BBrody8/21/2023
gotcha, i just need a good template icon at this point lol I'm not joking, I have no idea what to use as the icon, got any ideas?
AAyush8/21/2023
so what exactly is the template? is it generic template that will restart any service/project? Or only certain types i.e. docker, node etc? maybe like an hour glass figure?
BBrody8/21/2023
it can restart any railway service, doesnt matter what the service is
AAyush8/21/2023
i kinda like the hour glass figure but idk?
BBrody8/21/2023
ill see what i come up with, thanks!
Kkingoiscool8/21/2023
@Brody I am also interested - was looking for this exact functionality a few weeks ago
BBrody8/21/2023
ill keep you both posted
Solution
AAyush8/21/2023
Amazing thank you! Will give it a shot
BBrody8/21/2023
let me know if there are any difficulties
AAyush8/21/2023
just set it up now on my project. I have a schedule to restart my service at 12am AEST (roughly 7 hours from now). Will let you know how it goes
BBrody8/21/2023
awesome, how easy was the setup?
AAyush8/21/2023
Very easy but i had no idea bookmarlets was a thing lol 😂
BBrody8/21/2023
also, I don't know if I mentioned it in the readme, but the services cron schedule runs on UTC time
AAyush8/21/2023
oh gotcha makes sense. Will cater for that
BBrody8/21/2023
even railways native cron is utc you can just edit the cron expression in the variable and let the service redeploy
AAyush8/21/2023
sweet thanks fixed it up now, 0 12 * * * should be 12am AEST
BBrody8/21/2023
possibly, I don't actually know how to read a cron expression lol
AAyush8/21/2023
neither lol, im relying on chat gpt 😄
BBrody8/21/2023
but you'll get an error message in the deployment logs if the cron expression is invalid
BBrody8/22/2023
that's a calendar? did someone ping me?
AAyush8/22/2023
@Brody looks to be working!
AAyush8/22/2023
Thanks heaps for that template
BBrody8/22/2023
no problem, and if you run into any issues, let me know

Looking for more? Join the community!

Want results from more Discord servers?
Add your server
Recommended Posts
Can't set a private project to publicWhenever I try to set a private project to public, I get the error "All services in a public projectcan railway forward traffic to a self signed web application?i'm deploying an application and for some reason it needs to use self signed certificate, could railPrisma timeoutI am trying to use a fairly large query with Prisma and get `Timed out fetching a new connection frI want to run AirbyteI would like to use an ETL and I heard that Airbyte is good so I'm trying to set it up as a service NestJS application doesn't startHi, I'm trying to deploy a NestJS app but it gets stuck on a loop trying to start the server. I thiSQLite DatabaseIm trying to deplay a discord bot that uses an sqlite database. Ive created a persistent volume for About storageHello I'm newbie here, i just wanted to know how much storage will i have with the hobby plan?, I anode_modulesI'm trying to deploy using my build script. The build script consist in install normally the packageDefault Express template fails to deployHi, I've tried to deploy the ExpressJS template with no modifications, but am getting errors. Thx foQuestions about pricing for my customersHi, I'm planning to open a web agency and use Railway to deploy our customers' websites. Each customRailway IPv4Guys, does Railway "exports" IPv4 to another service allow its usage permission? I'm using a Redis s[PHP] Route all requests to index.phphttps://twitter.com/Shpigford/status/1693092242943025554I can't buy the planWhen I try to subscribe to the $5 plan, it gives me an error message saying "Your card does not suppI have a problem with my express applicationin the application status it says success but it is not displayed on the websitewhat is the reason for this error?npm WARN config production Use `--omit=dev` instead.Subscription already existsI can't enable the developer plan, the system returns the message: "Subscription already exists"FLASK APP failed to deployI used the refernce flask project idk why maybe the build/run command i put in was incorrect?503 error after binding to ipv6I get a 503 error after binding to ipv6 for internal communication between 2 services. attached my How do I link my services internally?Hello, I tried to figure it out on my own, but I have just ended up losing sleep haha. I'm having anBuild fails when pushing a project with docker-compose file.I am trying to link a project from cli and trying to push it to railway. i am using a docker compose