當 Daemon 死掉時自動重新跑起...

以前確保 daemon 掛掉時會重新跑起來大概有幾個方式,像是用 Monit 顧,然後再用 /etc/inittab 確保 Monit 不會掛掉...

systemd 的年代,因為 systemd 已經被保護起來,而重跑這個功能在 systemd 裡就有支援,不需要用 Monit 這類程式了。

manual 裡搜尋 restart 可以看到幾個參數:

  • Restart=
  • RestartForceExitStatus=
  • RestartPreventExitStatus=
  • RestartSec=

這次是遇到 SmokePing 的 FastCGI daemon 每隔幾天會自己死掉,導致 nginx 丟出 503 然後被 UptimeRobot 偵測到而拋出警告。

但這個問題只有在一台伺服器會發生,而 log 裡也沒翻到可以繼續 debug 的錯誤訊息,試著猜測一些情境去搜尋引擎找也沒翻到... 就決定先 workaround 來處理,然後就發現現在已經不太需要用 Monit 來處理這個問題了。

AWS CodeDeploy 支援單機測試模式

AWS CodeDeploy 本來是個 client-server 服務架構,但現在讓你方便在本機測試,支援直接在本機下指令 deploy (不需要 server) 看看發生什麼狀況:「AWS CodeDeploy Supports Local Testing and Debugging」。

Previously, if you wanted to test and debug your deployment, you had to fully configure AWS CodeDeploy. This includes installing the agent on the target host, creating a CodeDeploy Application, and creating a CodeDeploy Deployment Group.

Now, you can execute a deployment directly on a local machine or instance where the CodeDeploy agent is installed. If your deployment has errors, you can easily find and view the error logs by accessing the agent with your terminal. This makes it faster and easier to find and fix bugs before configuring CodeDeploy for production.

是有很多人一直中獎然後跟 AWS 反應嗎... XD

Pinterest 對 ZooKeeper 的用法

在「ZooKeeper Resilience at Pinterest」這篇文章裡面,Pinterest 的人說明內部是怎麼使用 ZooKeeper,其中對我來說最重要的是這張圖:

程式不直接接觸 ZooKeeper 取得資料,而是透過 daemon 寫到 local disk 的資料取得。這樣當 ZooKeeper 失敗時仍然可以保持一定的服務 (因為 local disk cache),而避免服務中斷。

當然,這跟資料的性質有關,不是所有的資料型態都可以接受 cache。這種解法常常是在穩定性不是可以自己控制 (這個例子裡是 ZooKeeper),而且遇到問題時不希望整個服務就爆炸...

但這個思路每次看過每次都會忘記,寫下來不知道會不會比較容易想起來 :o