Skip to content

Pm2 api doesn't work when called from app/module running in pm2 #3620

@rohit-gohri

Description

@rohit-gohri

I have an app that has some async tasks that I decided to designate to a child worker. Something like a queue worker, but that queue might get tasks from other apps too. So I made another app, queue-worker. To start and stop the app I am using the pm2 api to send message to the app, through which it can receive tasks and pause/resume processing of the queue.

Now when running the app with node, it correctly connects with pm2, and starts the worker or sends a message to resume processing if the worker is already started.

What's going wrong?

But when I run the app itself with pm2, the worker never starts. There are no errors or anything of that sorts. It just keeps waiting for a response message from the worker. And pm2 ls doesn't show the worker.

How could we reproduce this issue?

Make an app that uses pm2 api to start another app and run it using pm2.

Supporting information

Please run the following command (available on PM2 >= 2.6)

$ pm2 report

===============================================================================
--- PM2 REPORT (Fri Apr 20 2018 16:03:44 GMT+0530 (IST)) ----------------------
===============================================================================
--- Daemon --------------------------------------------------------------------
pm2d version         : 2.10.2
node version         : 8.11.1
node path            : /home/smpx-170l/projects/crawler/./node_modules/.bin/pm2
argv                 : /usr/bin/node,/home/smpx-170l/projects/crawler/node_modules/pm2/lib/Daemon.js
argv0                : node
user                 : smpx-170l
uid                  : 1000
gid                  : 1000
uptime               : 10min
===============================================================================
--- CLI -----------------------------------------------------------------------
local pm2            : 2.10.2
node version         : 8.11.1
node path            : /usr/bin/pm2
argv                 : /usr/bin/node,/usr/bin/pm2,report
argv0                : node
user                 : smpx-170l
uid                  : 1000
gid                  : 1000
===============================================================================
--- System info ---------------------------------------------------------------
arch                 : x64
platform             : linux
type                 : Linux
cpus                 : Intel(R) Core(TM) i7-4600U CPU @ 2.10GHz
cpus nb              : 4
freemem              : 1408094208
totalmem             : 8263081984
home                 : /home/smpx-170l
===============================================================================
--- PM2 list ------------------------------------------------------------------
┌─────────────────────────┬────┬─────────┬───────┬────────┬─────────┬────────┬─────┬────────────┬───────────┬──────────┐
│ App name                │ id │ mode    │ pid   │ status │ restart │ uptime │ cpu │ mem        │ user      │ watching │
├─────────────────────────┼────┼─────────┼───────┼────────┼─────────┼────────┼─────┼────────────┼───────────┼──────────┤
│ live-worker-development │ 0  │ cluster │ 10242 │ online │ 0       │ 10m    │ 0%  │ 134.1 MB   │ smpx-170l │ disabled │
└─────────────────────────┴────┴─────────┴───────┴────────┴─────────┴────────┴─────┴────────────┴───────────┴──────────┘
===============================================================================
--- Daemon logs ---------------------------------------------------------------
/home/smpx-170l/.pm2/pm2.log last 20 lines:
PM2        | [2018-04-20 15:52:51] PM2 log: ===============================================================================
PM2        | [2018-04-20 15:53:06] PM2 log: PM2 successfully stopped
PM2        | [2018-04-20 15:53:07] PM2 log: ===============================================================================
PM2        | [2018-04-20 15:53:07] PM2 log: --- New PM2 Daemon started ----------------------------------------------------
PM2        | [2018-04-20 15:53:07] PM2 log: Time                 : Fri Apr 20 2018 15:53:07 GMT+0530 (IST)
PM2        | [2018-04-20 15:53:07] PM2 log: PM2 version          : 2.10.2
PM2        | [2018-04-20 15:53:07] PM2 log: Node.js version      : 8.11.1
PM2        | [2018-04-20 15:53:07] PM2 log: Current arch         : x64
PM2        | [2018-04-20 15:53:07] PM2 log: PM2 home             : /home/smpx-170l/.pm2
PM2        | [2018-04-20 15:53:07] PM2 log: PM2 PID file         : /home/smpx-170l/.pm2/pm2.pid
PM2        | [2018-04-20 15:53:07] PM2 log: RPC socket file      : /home/smpx-170l/.pm2/rpc.sock
PM2        | [2018-04-20 15:53:07] PM2 log: BUS socket file      : /home/smpx-170l/.pm2/pub.sock
PM2        | [2018-04-20 15:53:07] PM2 log: Application log path : /home/smpx-170l/.pm2/logs
PM2        | [2018-04-20 15:53:07] PM2 log: Process dump file    : /home/smpx-170l/.pm2/dump.pm2
PM2        | [2018-04-20 15:53:07] PM2 log: Concurrent actions   : 2
PM2        | [2018-04-20 15:53:07] PM2 log: SIGTERM timeout      : 1600
PM2        | [2018-04-20 15:53:07] PM2 log: ===============================================================================
PM2        | [2018-04-20 15:53:17] PM2 log: Starting execution sequence in -cluster mode- for app name:live-worker-development id:0
PM2        | [2018-04-20 15:53:17] PM2 log: App name:live-worker-development id:0 online
PM2        | [2018-04-20 15:53:17] PM2 error: (node:10133) [DEP0007] DeprecationWarning: worker.suicide is deprecated. Please use worker.exitedAfterDisconnect.

Please copy/paste the above report in your issue on https://github.com/Unitech/pm2/issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions