if it's not too much trouble, you can try my php-stacktrace . There is no need to expand or restart the process. Just a PID, can read the memory of the PHP process, parse the call stack information, and know what the PHP process is doing.
A few dozen ms calls are made to save the result, which is a sample profiler:)
if you read the problem wrong, it turns out that it is a memory problem. You can directly use gdb dump memory and then check it slowly.
If there are not many blocks of
code, use memory_get_usage
to print the current memory usage.
php daemons generally have leakage problems, which in many cases are caused by extensions.
so the production environment recommends that every task executed, the counter + 1, when more than a certain amount, such as 100, exit the process, to ensure the complete execution of the business logic (if you quit, it may not be finished)
and then use nodejs's pm2
process to keep alive
.
pm2 configuration file example:
{
"name": "",
"script": "cli.php",
"exec_interpreter": "php",
"exec_mode": "fork",