@@ -25,7 +25,7 @@ public function __construct() {
2525 $ hcpp ->add_action ( 'pre_delete_web_domain_backend ' , [ $ this , 'pre_delete_web_domain_backend ' ] );
2626 $ hcpp ->add_action ( 'priv_suspend_web_domain ' , [ $ this , 'priv_suspend_web_domain ' ] );
2727 $ hcpp ->add_action ( 'priv_unsuspend_domain ' , [ $ this , 'priv_unsuspend_domain ' ] );
28- $ hcpp ->add_action ( 'priv_update_sys_queue ' , [ $ this , 'priv_update_sys_queue ' ] );
28+ $ hcpp ->add_action ( 'hcpp_rebooted ' , [ $ this , 'hcpp_rebooted ' ] );
2929 $ hcpp ->add_action ( 'hcpp_runuser ' , [ $ this , 'hcpp_runuser ' ] );
3030 }
3131
@@ -40,37 +40,27 @@ public function hcpp_runuser( $cmd ) {
4040 /**
4141 * Check if system has rebooted and restart apps
4242 */
43- public function priv_update_sys_queue ( $ args ) {
44- if ( isset ( $ args [0 ] ) && $ args [0 ] == 'restart ' ) {
43+ public function hcpp_rebooted ( $ args ) {
44+
45+ // Restart all PM2 apps for all user accounts
46+ $ users = scandir ('/home ' );
47+ global $ hcpp ;
48+ $ cmd = '' ;
49+ foreach ( $ users as $ user ) {
50+ // Ignore hidden files/folders and system folders
51+ if ( $ user == '. ' || $ user == '.. ' || $ user == 'lost+found ' || $ user == 'systemd ' ) {
52+ continue ;
53+ }
4554
46- // Check last reboot time
47- $ file = '/usr/local/hestia/data/hcpp/last_reboot.txt ' ;
48- $ last = shell_exec ("who -b " );
49- if ( !file_exists ( $ file ) || file_get_contents ( $ file ) !== $ last ) {
50- file_put_contents ( $ file , $ last );
51-
52- // Restart all PM2 apps for all user accounts
53- $ users = scandir ('/home ' );
54- global $ hcpp ;
55- $ cmd = '' ;
56- foreach ( $ users as $ user ) {
57- // Ignore hidden files/folders and system folders
58- if ( $ user == '. ' || $ user == '.. ' || $ user == 'lost+found ' || $ user == 'systemd ' ) {
59- continue ;
60- }
61-
62- // Check if the .pm2 folder exists in the user's home directory
63- if ( is_dir ( "/home/ $ user/.pm2 " ) ) {
55+ // Check if the .pm2 folder exists in the user's home directory
56+ if ( is_dir ( "/home/ $ user/.pm2 " ) ) {
6457
65- // Restart any pm2 processes
66- $ cmd .= 'runuser -s /bin/bash -l ' . $ user . ' -c "cd /home/ ' . $ user . ' && ' ;
67- $ cmd .= 'export NVM_DIR=/opt/nvm && source /opt/nvm/nvm.sh && pm2 resurrect" ' . "\n" ;
68- }
69- }
70- shell_exec ( $ hcpp ->do_action ( 'nodeapp_resurrect_apps ' , $ cmd ) );
58+ // Restart any pm2 processes
59+ $ cmd .= 'runuser -s /bin/bash -l ' . $ user . ' -c "cd /home/ ' . $ user . ' && ' ;
60+ $ cmd .= 'export NVM_DIR=/opt/nvm && source /opt/nvm/nvm.sh && pm2 resurrect" ' . "\n" ;
7161 }
7262 }
73- return $ args ;
63+ shell_exec ( $ hcpp -> do_action ( ' nodeapp_resurrect_apps ' , $ cmd ) ) ;
7464 }
7565
7666 /**
0 commit comments