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 jlist outputs more than json #281

Closed
aikomastboom opened this issue Jan 31, 2014 · 8 comments
Closed

pm2 jlist outputs more than json #281

aikomastboom opened this issue Jan 31, 2014 · 8 comments

Comments

@aikomastboom
Copy link

When running pm2 for the first time:

vagrant@precise64:$ rm -rf .pm2/
vagrant@precise64:
$ pm2 jlist -s
Initializing folder for pm2 on /home/vagrant/.pm2
Creating PM2 configuration file in /home/vagrant/.pm2/custom_options.sh
[]

It would be nice if the "Initializing .. options.sh" part would be suppressed as:

  • the output is not json anymore and breaks a json parser
  • -s is supposed to make it silent but doesn't make it silent enough.

vagrant@precise64:$ rm -rf .pm2/
vagrant@precise64:
$ pm2 jlist -s | json_pp
malformed JSON string, neither array, object, number, string or atom, at character offset 0 (before "Initializing folder ...") at /usr/bin/json_pp line 44

@vwal
Copy link
Contributor

vwal commented Feb 2, 2014

Additionally, when the daemon has been killed, on the first run afterwards an object is output from Satan.js in addition to the empty process list, like so:

[root@LOCALDEV:/usr/projects/pm2_nodetest] [02:49 CST]
# pm2 kill 
Daemon killed
[root@LOCALDEV:/usr/projects/pm2_nodetest] [02:49 CST]
# pm2 jlist -s
{ online: true, success: true, pid: 5195 }
[]

Any scripts that expect process list output, but that are not written to handle that initial object will break on the first run. Would it be possible to suppress the initial object, especially with the -s switch?

@Unitech Unitech mentioned this issue Apr 4, 2014
10 tasks
@aikomastboom
Copy link
Author

version 0.8.11

ok:

root:~# pm2 jlist
[{....}]

too silent:

root:~# pm2 jlist -s

too silent:

root:~# pm2 jlist -s --no-daemon

includes non json:

root:~# pm2 jlist --no-daemon
pm2 launched in no-daemon mode (you can add DEBUG="*" env variable to get more messages)
>> pm2 is already daemonized ! You should kill it before launching it in no-daemon mode
[{.....}]

@aikomastboom
Copy link
Author

pm2 -V 0.9.2 is still outputting non-json when asked to output json.. please add to 0.9.x roadmap :)

@aikomastboom
Copy link
Author

It got a little worse for me, because skipping stdout until first '[' breaks now too. not sure how to workaround this one:

root:~#pm2 jlist --no-daemon
pm2 launched in no-daemon mode (you can add DEBUG="*" env variable to get more messages)
[[[[ PM2/God daemon launched ]]]]
RPC interface [READY] on 6666:localhost
BUS system [READY] on  6667:localhost 
Interaction file does not exists
Error when getting / setting keys { msg: 'secret key is not defined' }
[]

@soyuka
Copy link
Collaborator

soyuka commented Aug 14, 2014

Fixed here: #627

@aikomastboom
Copy link
Author

I applied patch 2734f41 locally to verify.
however the issue is not (completely) resolved for me:

$npm install pm2

$./node_modules/.bin/pm2 jlist
Initializing folder for pm2 on /home/jenkins/.pm2
Creating PM2 configuration file in /home/jenkins/.pm2/custom_options.sh
[]

$./node_modules/.bin/pm2 jlist
[]

$./node_modules/.bin/pm2 jlist --no-daemon
pm2 launched in no-daemon mode (you can add DEBUG="*" env variable to get more messages)
>> pm2 is already daemonized ! You should kill it before launching it in no-daemon mode
[]

@rlidwka
Copy link
Collaborator

rlidwka commented Aug 16, 2014

Initializing folder for pm2 on /home/jenkins/.pm2
Creating PM2 configuration file in /home/jenkins/.pm2/custom_options.sh

This kind of stuff should be in stderr then.

@Unitech
Copy link
Owner

Unitech commented Nov 23, 2016

available in upcoming release

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

5 participants