0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【メモ】access.log 監視 → サービス再起動用シェルスクリプト

Posted at

サービスのリスタート用のシェルスクリプトを用意したのでそのメモ

# !/bin/sh

if [ $$ != `pgrep -fo $0`  ]; then
echo `basename $0` is already running.
exit 1
fi

restart(){
while read i
do
   echo $i | grep " 499 " | grep -v "除外条件"
 if [ $? = "0" ];then
   sudo -S /etc/rc.d/init.d/php-fpm restart
 fi
done
}

tail -n 0 --follow=name --retry /var/log/nginx/access.log | restart

原因不明の http status code 499 でサービス提供が停止してしまう現象が発生中。php-fpm のリスタートで、とりあえず復旧するので、暫定対応のため作成。たまに使いたくなる時があるはずなのでメモを残す。

シェルスクリプトは苦手だわ。。。
前半が重複起動抑止のためのスクリプト。後半がリスタート用。
tail -f を受け、499 に合致し、除外条件を含まないものが来た時、php-fpm のリスタートを実行。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?