Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PM2 Does not capture Python stdout #3076

Closed
NotSoSuper opened this issue Aug 8, 2017 · 5 comments
Closed

PM2 Does not capture Python stdout #3076

NotSoSuper opened this issue Aug 8, 2017 · 5 comments

Comments

@NotSoSuper
Copy link

What's going wrong?

When using PM2 to run a Python application none of the stdout from print or etc is captured to the log files.

How could we reproduce this issue?

Run a Python script such as print('test') with pm2 start test.py --interpreter python3.6
then pm2 logs

Supporting information

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

$ pm2 report
===============================================================================
--- PM2 REPORT (Tue Aug 08 2017 12:55:16 GMT-0400 (EDT)) ----------------------
===============================================================================
--- Daemon -------------------------------------------------
pm2d version         : 2.6.1
node version         : 7.10.1
node path            : /usr/bin/pm2
argv                 : /usr/bin/nodejs,/usr/lib/node_modules/pm2/lib/Daemon.js
argv0                : node
user                 : notsobot
uid                  : 1001
gid                  : 1012
uptime               : 147min
===============================================================================
--- CLI ----------------------------------------------------
local pm2            : 2.6.1
node version         : 7.10.1
node path            : /usr/bin/pm2
argv                 : /usr/bin/nodejs,/usr/bin/pm2,report
argv0                : node
user                 : notsobot
uid                  : 1001
gid                  : 1012
===============================================================================
--- System info --------------------------------------------
arch                 : x64
platform             : linux
type                 : Linux
cpus                 : Intel(R) Xeon(R) CPU E5-1650 v2 @ 3.50GHz
cpus nb              : 12
freemem              : 895717376
totalmem             : 33701502976
home                 : /home/notsobot
===============================================================================
--- PM2 list -----------------------------------------------
┌────────────────────┬────┬──────┬───────┬────────┬─────────┬────────┬─────┬────────────┬──────────┬──────────┐
│ App name           │ id │ mode │ pid   │ status │ restart │ uptime │ cpu │ mem        │ user     │ watching │
├────────────────────┼────┼──────┼───────┼────────┼─────────┼────────┼─────┼────────────┼──────────┼──────────┤
│ bot00              │ 1  │ fork │ 9739  │ online │ 0       │ 21m    │ 6%  │ 623.8 MB   │ notsobot │ disabled │
│ pm2-http-interface │ 0  │ fork │ 25512 │ online │ 0       │ 87m    │ 0%  │ 38.3 MB    │ notsobot │ disabled │
└────────────────────┴────┴──────┴───────┴────────┴─────────┴────────┴─────┴────────────┴──────────┴──────────┘
===============================================================================
--- Daemon logs --------------------------------------------
/home/notsobot/.pm2/pm2.log last 20 lines:
PM2        | 2017-08-08 10:27:26: PM2 PID file         : /home/notsobot/.pm2/pm2.pid
PM2        | 2017-08-08 10:27:26: RPC socket file      : /home/notsobot/.pm2/rpc.sock
PM2        | 2017-08-08 10:27:26: BUS socket file      : /home/notsobot/.pm2/pub.sock
PM2        | 2017-08-08 10:27:26: Application log path : /home/notsobot/.pm2/logs
PM2        | 2017-08-08 10:27:26: Process dump file    : /home/notsobot/.pm2/dump.pm2
PM2        | 2017-08-08 10:27:26: Concurrent actions   : 2
PM2        | 2017-08-08 10:27:26: SIGTERM timeout      : 1600
PM2        | 2017-08-08 10:27:26: ===============================================================================
PM2        | 2017-08-08 11:18:59: Starting execution sequence in -fork mode- for app name:pm2-http-interface id:0
PM2        | 2017-08-08 11:18:59: App name:pm2-http-interface id:0 online
PM2        | 2017-08-08 11:27:33: 0
PM2        | 2017-08-08 11:27:33: Stopping app:pm2-http-interface id:0
PM2        | 2017-08-08 11:27:33: App [pm2-http-interface] with id [0] and pid [23425], exited with code [0] via signal [SIGINT]
PM2        | 2017-08-08 11:27:33: pid=23425 msg=process killed
PM2        | 2017-08-08 11:27:38: Starting execution sequence in -fork mode- for app name:pm2-http-interface id:0
PM2        | 2017-08-08 11:27:38: App name:pm2-http-interface id:0 online
PM2        | 2017-08-08 11:28:22: 25512 : id unknown
PM2        | 2017-08-08 11:28:33: 25512 : id unknown
PM2        | 2017-08-08 12:33:42: Starting execution sequence in -fork mode- for app name:bot00 id:1
PM2        | 2017-08-08 12:33:42: App name:bot00 id:1 online
@vmarchaud
Copy link
Contributor

Can't produce :
image

@martinsteinorth
Copy link

Having the same problem with long running python scripts. I get the output if the script terminates on its own, but there is no output if it is a long running script.

Try

import time
while True:
    print("PING")
    time.sleep(1)

PM2 2.9.3
Node 8.9.4
Linux on arm arch

@Unitech Unitech reopened this Aug 27, 2018
@Unitech
Copy link
Owner

Unitech commented Aug 27, 2018

PYTHONUNBUFFERED=x

Unitech added a commit that referenced this issue Aug 27, 2018
@Unitech
Copy link
Owner

Unitech commented Aug 27, 2018

fixed, it will land on next release

@Unitech
Copy link
Owner

Unitech commented Sep 20, 2018

It has been fixed and landed on the latest pm2 version, check it out:

npm install pm2 -g
pm2 update

Also checkout this article about the support of PM2 for Python: https://blog.pm2.io/managing-python-application-with-pm2/

@Unitech Unitech closed this as completed Sep 20, 2018
inerc pushed a commit to inerc/pm2 that referenced this issue Feb 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants