R
Railway•2y ago
xRapids

Is there a way to redeploy application automatically

Hi, I was wondering if there is a way to schedule automatic redeploys. E.g. Redeploys the web application every 2 days.
69 Replies
Percy
Percy•2y ago
Project ID: 75d80f5b-a3d6-4015-a435-1cf91309a053
xRapids
xRapidsOP•2y ago
75d80f5b-a3d6-4015-a435-1cf91309a053
xRapids
xRapidsOP•2y ago
I'll havea look thanks Does railway.app have cronjobs?
Adam
Adam•2y ago
not built in, but you can set an endpoint that crashes your app and use another service that just triggers that endpoint on a cron schedule Set your app to always restart on crash but github actions are a more elegant solution
Brody
Brody•2y ago
your question has been answered, but I'm just wondering, why do you want to restart your app every 2 days?
xRapids
xRapidsOP•2y ago
Becasue for some reason the website goes very very slow and barely loads Without a restart Do you know any tutorials they may do this I've searched but not sure how I would do this
Brody
Brody•2y ago
how about we try to get to the route cause of this issue instead of applying a bandaid solution what kind of website is it?
xRapids
xRapidsOP•2y ago
Just a general project website Django
Brody
Brody•2y ago
well hold on, let's try to fix the cause of the slowdown if possible
xRapids
xRapidsOP•2y ago
That's a scheduling a job, rather than restart. I read it Yes
Brody
Brody•2y ago
let's put the restarting off to the side for now, okay? can you share a link to your repo?
xRapids
xRapidsOP•2y ago
It's private currently I can send alternative that's same files
Brody
Brody•2y ago
do you have a Procfile?
xRapids
xRapidsOP•2y ago
But some credential files missing Yes
Brody
Brody•2y ago
send it?
xRapids
xRapidsOP•2y ago
This is the repo https://github.com/Abid-M/Energy-Management-System I dont use this repo specifically for railway
GitHub
FYP - https://re-energise.xyz/. Contribute to Abid-M/Energy-Management-System development by creating an account on GitHub.
xRapids
xRapidsOP•2y ago
as the private one, for this one there is like i commented the sensitive info out but basically is the same
Brody
Brody•2y ago
show me the procfile for the app that's slowing down please
xRapids
xRapidsOP•2y ago
web: gunicorn EnergyProject.wsgi
Brody
Brody•2y ago
okay and what specifically is slowing down? be as specific as humanly possible
xRapids
xRapidsOP•2y ago
legit the whole website is slow to load and all i havent used the website maybe in like a month and like it took id say 30+ seconds more to load the website
Brody
Brody•2y ago
is it currently slow?
xRapids
xRapidsOP•2y ago
and somoe not even once i redeployed it, it seemed fine abit not atm as i redployed it recently restart
Brody
Brody•2y ago
are you calling any external storage or api services during incoming requests to the site? or accessing a database perhaps?
xRapids
xRapidsOP•2y ago
yes
Brody
Brody•2y ago
yes to what lol
xRapids
xRapidsOP•2y ago
i got postgresql on railway
Brody
Brody•2y ago
have you taken a look at the apps metrics during a time of slowness?
xRapids
xRapidsOP•2y ago
Brody
Brody•2y ago
I meant the django service
xRapids
xRapidsOP•2y ago
Brody
Brody•2y ago
no stair step memory or cpu usage, looks fine to me that repo you linked, that's your repo running in production, minus the sensitive information? correct?
xRapids
xRapidsOP•2y ago
yes correct
Brody
Brody•2y ago
I'm seeing some things that stand out to me, don't know if they would cause slow downs though 1. your app is set to debug mode, set it to false 2. you have a live reload middleware, remove that middleware
xRapids
xRapidsOP•2y ago
alrighty ill try them
Brody
Brody•2y ago
since you are disabling debug mode, you will likely need to run collect static manually now you can view the start command for the railway provided django template here: https://github.com/railwayapp-templates/django/blob/main/railway.json
xRapids
xRapidsOP•2y ago
on:
schedule:
- cron: "0 0 */2 * *"

jobs:
redeploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Redeploy
run: python manage.py migrate && python manage.py collectstatic --noinput && gunicorn mysite.wsgi
on:
schedule:
- cron: "0 0 */2 * *"

jobs:
redeploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Redeploy
run: python manage.py migrate && python manage.py collectstatic --noinput && gunicorn mysite.wsgi
?
Brody
Brody•2y ago
what what is that 1. we said we are putting that aside for now in favour of trying to fix the root cause 2. that's not even remotely close to how you would actually do it
xRapids
xRapidsOP•2y ago
in general when i was developing locally, it was very slow, took 4 seconds to load pages in once deployed on railway better, but still not fluid and just tested couple days back after leaving it deployed for couple weeks or slow and tried loading and basically never loaded
Brody
Brody•2y ago
have you made those two changes i suggested
xRapids
xRapidsOP•2y ago
i have done now yh its actually
Brody
Brody•2y ago
show me your new procfile please
xRapids
xRapidsOP•2y ago
decent now sure
xRapids
xRapidsOP•2y ago
Brody
Brody•2y ago
have you set debug = false? have you removed the live reload middleware?
xRapids
xRapidsOP•2y ago
i have done now yh
Brody
Brody•2y ago
both things?
xRapids
xRapidsOP•2y ago
Yeah I have done both
Brody
Brody•2y ago
and what are the response times for the first network request
xRapids
xRapidsOP•2y ago
in metrics?
Brody
Brody•2y ago
no in the browser tools in the network tab
xRapids
xRapidsOP•2y ago
"can't reach this page" if its on normal private browser shows as 135.99ms
Brody
Brody•2y ago
screenshot please
xRapids
xRapidsOP•2y ago
Brody
Brody•2y ago
it loads plenty fast for me
xRapids
xRapidsOP•2y ago
yh seems fine now, with a different browser debug set to false actually made like a lot of difference tbh like alot alot
Brody
Brody•2y ago
but you did remove the live reload middleware too right?
xRapids
xRapidsOP•2y ago
i removed that as well yh, it could be that too yh appreciate the help, seems v good now oh wait the static some images seem not showing
Brody
Brody•2y ago
remember when i said this lmao?
xRapids
xRapidsOP•2y ago
yeah how can i fix it and do it manually from the link u sent
Brody
Brody•2y ago
do you see the start command? from the link i sent
xRapids
xRapidsOP•2y ago
yh
Brody
Brody•2y ago
well delete your Procfile, and use that railway.json file in your own project, just update the apps name that gunicorn starts
xRapids
xRapidsOP•2y ago
Yeah all good now Thank you, appreciate the help! no need the restart thing anymore hopefully
Brody
Brody•2y ago
if things slow down again, dont restart it, come back here and ping me please
xRapids
xRapidsOP•2y ago
For sure, thanks
Brody
Brody•2y ago
no problem 🙂
Want results from more Discord servers?
Add your server