gpt4 book ai didi

linux - 使用 Cron Job 检查我的 mod_wsgi/apache 服务器是否正在运行并重新启动

转载 作者:太空宇宙 更新时间:2023-11-04 09:33:10 25 4
gpt4 key购买 nike

我和我的小组正在运行一个基于 Django 并使用 mod_wsgi 来运行 Apache 服务器的服务器。项目结束后我们将不再处理这个项目,所以我尝试设置 cronjob 类似的功能来检查 apache 服务器是否已关闭(系统重启或电源故障),如果已关闭,将重新启动服务器我。我找到了有关如何检查 apache 服务器是否关闭并在关闭时重新启动服务器的文档,但我们的服务器使用 https,因此我们的启动命令非常冗长。

我可以简单地使用这些示例中提供的功能吗:

https://askubuntu.com/questions/277389/cron-job-to-restart-apache

https://www.digitalocean.com/community/tutorials/how-to-use-a-simple-bash-script-to-restart-server-programs

或者我是否需要更复杂的过程才能实现这一点?

我们用来初始启动服务器的命令是

python manage.py runmodwsgi --host 0.0.0.0 --port 8001 --https-port 8000 --ssl-certificate(证书位置)--server-name(域名)

我是 Linux 的新手,同时使用 Mod-wsgi 和 Apache,所以非常感谢任何帮助。

最佳答案

我想这不是解决这个问题的好方法。

我建议您使用 monit ( https://mmonit.com/ )。这是用于检查服务的很酷的程序。

apt-get install monit

Apache 重启配置指令:

check process httpd with pidfile /var/run/httpd.pid
group apache
start program = "/etc/init.d/httpd start"
stop program = "/etc/init.d/httpd stop"
if failed host 127.0.0.1 port 80
protocol http then restart
if 5 restarts within 5 cycles then timeout

关于linux - 使用 Cron Job 检查我的 mod_wsgi/apache 服务器是否正在运行并重新启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29403259/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com