@@ -36,69 +36,82 @@ module.exports = function(CLI) {
36
36
* @method getVersion
37
37
* @callback cb
38
38
*/
39
- CLI . prototype . report = function ( cb ) {
39
+ CLI . prototype . report = function ( ) {
40
40
var that = this ;
41
+ var semver = require ( 'semver' ) ;
41
42
42
- var Log = require ( './Log' ) ;
43
-
44
- that . Client . executeRemote ( 'getReport' , { } , function ( err , report ) {
45
- fmt . sep ( ) ;
46
- fmt . title ( 'PM2 REPORT (' + new Date ( ) + ')' ) ;
47
- fmt . sep ( ) ;
48
- fmt . title ( chalk . bold . blue ( 'Daemon' ) ) ;
49
- fmt . field ( 'pm2d version' , report . pm2_version ) ;
50
- fmt . field ( 'node version' , report . node_version ) ;
51
- fmt . field ( 'node path' , report . node_path ) ;
52
- fmt . field ( 'argv' , report . argv ) ;
53
- fmt . field ( 'argv0' , report . argv0 ) ;
54
- fmt . field ( 'user' , report . user ) ;
55
- fmt . field ( 'uid' , report . uid ) ;
56
- fmt . field ( 'gid' , report . gid ) ;
57
- fmt . field ( 'uptime' , moment ( new Date ( ) ) . diff ( report . started_at , 'minute' ) + 'min' ) ;
58
-
59
- fmt . sep ( ) ;
60
- fmt . title ( chalk . bold . blue ( 'CLI' ) ) ;
61
- fmt . field ( 'local pm2' , pkg . version ) ;
62
- fmt . field ( 'node version' , process . versions . node ) ;
63
- fmt . field ( 'node path' , process . env [ '_' ] ) ;
64
- fmt . field ( 'argv' , process . argv ) ;
65
- fmt . field ( 'argv0' , process . argv0 ) ;
66
- fmt . field ( 'user' , process . env . USER ) ;
67
- fmt . field ( 'uid' , process . geteuid ( ) ) ;
68
- fmt . field ( 'gid' , process . getegid ( ) ) ;
69
-
70
- var os = require ( 'os' ) ;
71
-
72
- fmt . sep ( ) ;
73
- fmt . title ( chalk . bold . blue ( 'System info' ) ) ;
74
- fmt . field ( 'arch' , os . arch ( ) ) ;
75
- fmt . field ( 'platform' , os . platform ( ) ) ;
76
- fmt . field ( 'type' , os . type ( ) ) ;
77
- fmt . field ( 'cpus' , os . cpus ( ) [ 0 ] . model ) ;
78
- fmt . field ( 'cpus nb' , Object . keys ( os . cpus ( ) ) . length ) ;
79
- fmt . field ( 'freemem' , os . freemem ( ) ) ;
80
- fmt . field ( 'totalmem' , os . totalmem ( ) ) ;
81
- fmt . field ( 'home' , os . homedir ( ) ) ;
43
+ function reporting ( cb ) {
82
44
83
- that . Client . executeRemote ( 'getMonitorData' , { } , function ( err , list ) {
45
+ var Log = require ( './Log' ) ;
84
46
47
+ that . Client . executeRemote ( 'getReport' , { } , function ( err , report ) {
48
+ fmt . sep ( ) ;
49
+ fmt . title ( 'PM2 REPORT (' + new Date ( ) + ')' ) ;
85
50
fmt . sep ( ) ;
86
- fmt . title ( chalk . bold . blue ( 'PM2 list' ) ) ;
87
- that . list ( ) ;
51
+ fmt . title ( chalk . bold . blue ( 'Daemon' ) ) ;
52
+ fmt . field ( 'pm2d version' , report . pm2_version ) ;
53
+ fmt . field ( 'node version' , report . node_version ) ;
54
+ fmt . field ( 'node path' , report . node_path ) ;
55
+ fmt . field ( 'argv' , report . argv ) ;
56
+ fmt . field ( 'argv0' , report . argv0 ) ;
57
+ fmt . field ( 'user' , report . user ) ;
58
+ fmt . field ( 'uid' , report . uid ) ;
59
+ fmt . field ( 'gid' , report . gid ) ;
60
+ fmt . field ( 'uptime' , moment ( new Date ( ) ) . diff ( report . started_at , 'minute' ) + 'min' ) ;
88
61
89
- UX . dispAsTable ( list , that . gl_interact_infos ) ;
62
+ fmt . sep ( ) ;
63
+ fmt . title ( chalk . bold . blue ( 'CLI' ) ) ;
64
+ fmt . field ( 'local pm2' , pkg . version ) ;
65
+ fmt . field ( 'node version' , process . versions . node ) ;
66
+ fmt . field ( 'node path' , process . env [ '_' ] ) ;
67
+ fmt . field ( 'argv' , process . argv ) ;
68
+ fmt . field ( 'argv0' , process . argv0 ) ;
69
+ fmt . field ( 'user' , process . env . USER ) ;
70
+ fmt . field ( 'uid' , process . geteuid ( ) ) ;
71
+ fmt . field ( 'gid' , process . getegid ( ) ) ;
72
+
73
+ var os = require ( 'os' ) ;
90
74
91
75
fmt . sep ( ) ;
92
- fmt . title ( chalk . bold . blue ( 'Daemon logs' ) ) ;
93
- Log . tail ( [ {
94
- path : cst . PM2_LOG_FILE_PATH ,
95
- app_name : 'PM2' ,
96
- type : 'PM2'
97
- } ] , 20 , false , function ( ) {
98
- console . log ( chalk . bold . green ( 'Please copy/paste the above report in your issue on https://github.com/Unitech/pm2/issues' ) ) ;
99
- that . exitCli ( cst . SUCCESS_EXIT ) ;
76
+ fmt . title ( chalk . bold . blue ( 'System info' ) ) ;
77
+ fmt . field ( 'arch' , os . arch ( ) ) ;
78
+ fmt . field ( 'platform' , os . platform ( ) ) ;
79
+ fmt . field ( 'type' , os . type ( ) ) ;
80
+ fmt . field ( 'cpus' , os . cpus ( ) [ 0 ] . model ) ;
81
+ fmt . field ( 'cpus nb' , Object . keys ( os . cpus ( ) ) . length ) ;
82
+ fmt . field ( 'freemem' , os . freemem ( ) ) ;
83
+ fmt . field ( 'totalmem' , os . totalmem ( ) ) ;
84
+ fmt . field ( 'home' , os . homedir ( ) ) ;
85
+
86
+ that . Client . executeRemote ( 'getMonitorData' , { } , function ( err , list ) {
87
+
88
+ fmt . sep ( ) ;
89
+ fmt . title ( chalk . bold . blue ( 'PM2 list' ) ) ;
90
+ that . list ( ) ;
91
+
92
+ UX . dispAsTable ( list , that . gl_interact_infos ) ;
93
+
94
+ fmt . sep ( ) ;
95
+ fmt . title ( chalk . bold . blue ( 'Daemon logs' ) ) ;
96
+ Log . tail ( [ {
97
+ path : cst . PM2_LOG_FILE_PATH ,
98
+ app_name : 'PM2' ,
99
+ type : 'PM2'
100
+ } ] , 20 , false , function ( ) {
101
+ console . log ( chalk . bold . green ( 'Please copy/paste the above report in your issue on https://github.com/Unitech/pm2/issues' ) ) ;
102
+ that . exitCli ( cst . SUCCESS_EXIT ) ;
103
+ } ) ;
100
104
} ) ;
101
105
} ) ;
106
+ }
107
+
108
+ that . Client . executeRemote ( 'getVersion' , { } , function ( err , data ) {
109
+ if ( semver . satisfies ( data , '>= 2.6.0' ) )
110
+ reporting ( ) ;
111
+ else {
112
+ Common . printError ( cst . PREFIX_MSG_ERR + 'You need to update your Daemon, please type `$ pm2 update`' ) ;
113
+ that . exitCli ( cst . ERROR_EXIT ) ;
114
+ }
102
115
} ) ;
103
116
} ;
104
117
0 commit comments