As described in the title, when kill_timeout is defined, there's a random chance PM2 will fail to restart the process, failing with the message [PM2][ERROR] Process 1 not found. My environment runs a python script that constantly runs, and reboots once the process reaches a memory limit monitored by PM2. I've defined kill_timeout because PM2's logs become spammy during reboots while it's waiting for the process to exit, before outright killing the process after a number of milliseconds. Since I'd prefer the process die immediately, I set kill_timeout to 80. This worked initially, but now this edge-case has become so prevalent that it's not possible to use this feature in a production environment as it leave at least one of my processes dead when restarting it automatically. The odd thing is that it's easier to reproduce this issue manually with the pm2 restart [app_name] command than it is with pm2 stop [app_name] and pm2 start [app_name]. Not certain what the issue is, though it seems like it may be timing related.
My pm2.yml is as follows:
apps:
- name: 'app_name'
cwd: '/path/to/app'
script: '/path/to/app/.venv/bin/python'
args: '...'
watch: false
instances: 1
max_memory_restart: '10240M'
wait_ready: true
listen_timeout: 8000
kill_timeout: 80
...
Let me know if further information is required. Thank you.
As described in the title, when
kill_timeoutis defined, there's a random chance PM2 will fail to restart the process, failing with the message[PM2][ERROR] Process 1 not found. My environment runs a python script that constantly runs, and reboots once the process reaches a memory limit monitored by PM2. I've definedkill_timeoutbecause PM2's logs become spammy during reboots while it's waiting for the process to exit, before outright killing the process after a number of milliseconds. Since I'd prefer the process die immediately, I setkill_timeoutto 80. This worked initially, but now this edge-case has become so prevalent that it's not possible to use this feature in a production environment as it leave at least one of my processes dead when restarting it automatically. The odd thing is that it's easier to reproduce this issue manually with thepm2 restart [app_name]command than it is withpm2 stop [app_name]andpm2 start [app_name]. Not certain what the issue is, though it seems like it may be timing related.My pm2.yml is as follows:
Let me know if further information is required. Thank you.