@@ -113,6 +113,7 @@ public function do_maintenance( $majors = [], $cb_maintenance = null ) {
113113 $ pm2_list = [];
114114 foreach ( $ users as $ user ) {
115115 $ pm2 = $ this ->get_pm2_list ( $ user );
116+ if ( is_null ( $ pm2 ) ) continue ;
116117 foreach ( $ pm2 as $ p ) {
117118 if ( $ p ['pm2_env ' ]['status ' ] == 'online ' ) {
118119 $ version = $ p ['pm2_env ' ]['exec_interpreter ' ];
@@ -316,7 +317,9 @@ public function get_pm2_list( $user = '""' ) {
316317 }
317318 }
318319 global $ hcpp ;
319- $ list = json_decode ( $ hcpp ->run ("v-invoke-plugin nodeapp_pm2_jlist " . $ user ), true );
320+ $ list = $ hcpp ->run ("v-invoke-plugin nodeapp_pm2_jlist " . $ user );
321+ $ list = '[ ' . $ hcpp ->delLeftMost ( $ list , '[ ' );
322+ $ list = json_decode ( $ list , true );
320323 return $ list ;
321324 }
322325
@@ -450,15 +453,17 @@ public function hcpp_invoke_plugin( $args ) {
450453 }
451454
452455 // Restart via config.js filename; find by pm2_id
453- $ list = json_decode ( $ hcpp ->runuser ( $ username , 'pm2 jlist ' ), true );
456+ $ list = $ hcpp ->runuser ( $ username , 'pm2 jlist ' );
457+ $ list = '[ ' . $ hcpp ->delLeftMost ( $ list , '[ ' );
458+ $ list = json_decode ( $ list , true );
454459 $ cmd = '' ;
455460 foreach ( $ pm2_ids as $ id ) {
456461 foreach ( $ list as $ app ) {
457462 if ( $ app ['pm_id ' ] == $ id ) {
458463
459464 // Get the config.js file based on the script file
460- $ config = $ app ['pm2_env ' ][ ' script ' ] ;
461- $ config = $ hcpp -> delRightMost ( $ config , ' . ' ) . '.config.js ' ;
465+ $ config = $ hcpp -> getLeftMost ( $ app ['name ' ], ' | ' ) ;
466+ $ config = $ app [ ' pm2_env ' ][ ' cwd ' ] . ' / ' . $ config . '.config.js ' ;
462467 if ( $ config != '' ) {
463468 $ cmd .= 'pm2 restart ' . $ config . '; ' ;
464469 }
0 commit comments