Unitech / Unitech/pm2

Processes randomly error out upon reboot with kill_timeout defined

Open
#6,119 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
43.3k
Forks
2.7k
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure with the supplied pm2.yml, especially kill_timeout: 80, using pm2 restart [app_name] and comparing it with pm2 stop [app_name] followed by pm2 start [app_name]. Trace the restart behavior around the reported "Process 1 not found" error. Done means the configured process reliably restarts after reboot or restart without being left dead.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs, python, yaml
Domain
cli, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.