[英]How do i restart NGINX daemon Process in linux server if a website hosted on the same server fails to load?
我有一個網站托管在 ubuntu 20.04 上運行的 linux 服務器上。 有時網站無法加載並且它也會導致生產停機,如果重新啟動 nginx 進程,它就會工作。 So How do i write a script in python or shell script to restart nginx process only if the website goes down with a http code - 502?
首先,我建議您調查問題的根本原因 - 是什么導致 nginx 進程失敗? 您的服務器是否正在啟動不同的進程並用完 memory? 像ntop這樣的工具可以在這里提供幫助。
其次,要在 nginx 服務宕機時自動重啟,您可以通過運行sudo systemctl edit nginx
並添加代碼片段來編輯nginx.service
文件:
[Service]
Restart=on-failure
這將確保如果進程失敗,它將自動重新啟動。 話雖這么說,我強烈建議首先調查根本原因,以避免將來出現問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.