Answer the question
In order to leave comments, you need to log in
How to automatically start a project when it crashes?
Good evening.
I want to know how it is possible to implement the ability to check the status of the site's response, if the status is different from successful (200), then do the following in turn:
1. Check the status of the site's response, if the status is different from successful (200), then follow step 2 2.
Do a reboot now of the server.
3. Next, when raising the server, go to screen -S site
4. Inside the screen, go to the desired directory cd /var/www/site.ru
5. Run the yarn build && yarn start command
6. Then monitor point 1.
I have never done this, but would like to implement. I do not know yet where to dig even.
Thank you.
Answer the question
In order to leave comments, you need to log in
there are no problems, but Linux is not Windows, so it’s not accepted here
if one of the demons falls, they restart it and not the entire OS.
Uptime of 1000 days is quite an adequate uptime for ordinary home servers.
So the restart of the entire wasp is you throw it.
The technology is like that.
1. check statuses httpd nginx and mysql volume of memory disk space and what do you need
if they return true then nothing if fels then restart the specific daemon.
it is done in one line
it is done very easily
команда $$ echo "true" || echo "false"
For example, if you do
service httpd status | grep "running" || service httpd restart
It looks like you're already running your project wrong.
reboot now do you want to reboot directly at the operating system level? Why so radical?
Why go to the screen? I'll take a guess - yarn start ends when you exit the server and you decide to run it in a screen?
Well, that's it.
See. You can make it more reliable
1) install pm2 - a process manager for long-lived nodejs applications 2) write an ecosystem file
as simple as two pennies
3) run your creation not in the screen, and exit the server, do not be afraid that it will fall
Next, you can organize an application restart. Not a server.
The easiest way is to install a cron script on the same server that will do curl -s -o /dev/null -w "%{http_code}". If the response of this command is not "200", then execute the command pm2 restart myApp
By the way, if interruptions in the application are due to the fact that the process is crashing, then even no cron is needed - pm2 itself monitors that the application has stopped and starts it again.
What is the difficulty? Write a script with your check that does what you need, add it to cron.
on the site itself, make a script that, through wget curl, receives a random page, if instead of pages error 200, then it restarts the program on which your site is spinning.
why the server to reboot?? and what does the yarn package manager have to do with it??
find the point of failure and restart it if nothing better comes to mind.
I advise you to paint what kind of site you have there - a technically competent question will give a technically competent answer.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question