PHP uses supervisor and redis's brpop to implement message queues

supervisor configuration

[program:iotvisitorlog]
command=php yiic iotvisitorlog              ; the program (relative uses PATH, can take args)
numprocs=1                    ; number of processes copies to start (def 1)
directory=/opt/www                ; directory to cwd to before exec (def no cwd)
autostart=true                ; start at supervisord start (default: true)
autorestart=unexpected        ; whether/when to restart (default: unexpected)
startretries=1000
user=root

Ideas:

1. Resident script brpop($foo_key, 0 );

2. Execute for an hour || Processed 10,000 tasks || If the database connection is broken, sleep(5); exit(); Let the supervisor restart the process

Question: 1. What should I do if the maximum connection time of redis expires? 2. What should I do if the maximum execution time of PHP exceeds?
Answer: I haven't found the settings yet, it may be to let the supervisor restart

Guess you like

Origin blog.csdn.net/weixin_38230961/article/details/111942633