0

There is a script (found here), intended to monitor a log file: if keyword triggers then execute a command:

journalctl -f | \
while read line ; do
    echo "$line" | grep "apcu"
    if [ $? = 0 ]
    then
           systemctl restart php7.2-fpm.service
    fi
done 

I created and enabled a systemd service with this lines:

[Service]
ExecStart=/home/alex/journal-trigger.sh
StandardOutput=file:/home/alex/journal-trigger.log
StandardError=file:/home/alex/journal-trigger.error.log

This is a temporary measure, which restarts php service when apcu.so module fails. However, I faced one downside (when a command comprises 'apcu'):

sudo php cachetool.phar apcu:cache:info --fcgi

In FastCGI.php line 133:          
  FastCGI error: Stream got blocked, or terminated. (/var/run/php/php7.2-fpm.sock)

In Socket.php line 525:
  Stream got blocked, or terminated.

How can I fix it?

  • If your grep is not specific enough, then change your grep to match the message you actually want to match? This looks really fragile though, I'd be inclined to do it based on application metrics (or the lack thereof) instead if possible. – Chris Down Apr 1 at 16:46
  • I see, thanks, grep + regular expression. More robust solution I hope I will find soon. – Parks Apr 1 at 16:58
0

Ok, I fixed this issue by grep kernel\:\ traps\:.*apcu\.so
But the real fix was at the application level: apcu_clear_cache() was unintentionally left in my PHP code on prod server...

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.