0

There are some critical processes in my php-worker docker I need to make sure supervisor starts them correctly, if not I will need to restart my docker.

I have searched the supervisor document but I can't find an easy way to record all the FATAL processes by supervisor. So now I write TWO cronjob , first to check supervisorctl output periodically, something like this,

supervisorctl status | awk  '{if ($2 =="FATAL") {split($1,a,":"); print a[1]}}'
// If the output is not empty I record the process name into a file

The second cronjob to check periodically if that particular file exists and if the critical process I need exists in this file.

I feel awkward for this home-made solution. So is there a better way to do this ?

BTW, what I want is to find a way to record all the FATAL process but NOT to let supervisorctl restart them (I know how to do that, e.g. a simple modification to my script)

PS, I also searched SO and only find this How to get supervisorctl status of processes?, which is not what I need.

Qiulang
  • 10,295
  • 11
  • 80
  • 129
  • Can you split this into separate containers, one process per container, without using supervisord? Then you could start some of them with different Docker restart policies, and you could monitor the setup without needing Docker debugging commands. – David Maze Apr 13 '23 at 10:05
  • I know what you mean but for laravel worker container, it is normal to use supervisor to start several subprocesses, e.g. laravel worker queues. – Qiulang Apr 13 '23 at 13:55
  • Besides, some worker queue has low priority and if it don't start correctly I don't need to restart the docker. – Qiulang Apr 14 '23 at 06:32

1 Answers1

0

Try

supervisorctl status | grep FATAL | awk '{print $1}' | awk -F ':' '{print $1 ":*"}' | uniq | xargs -I {} supervisorctl restart {}
Richard Rublev
  • 7,718
  • 16
  • 77
  • 121
  • 1
    That is NOT what I want. I know I can use the command like that to `supervisorctl restart` but what I want is to find if there is a place (better builtin) to record all the FATAL process, which is my question. – Qiulang Apr 13 '23 at 06:27
  • @Qiulang You then want to check some logs? – Richard Rublev Apr 13 '23 at 13:23
  • 1
    Then checking supervisorctl status is easier. I just want to know if there is any builtin solution. – Qiulang Apr 13 '23 at 13:58