@@ -67,6 +67,7 @@ public function __construct() {
67
67
$ hcpp ->add_action ( 'v_unsuspend_domain ' , [ $ this , 'v_unsuspend_domain ' ] ); // Individually unsuspend domain only throws this event
68
68
$ hcpp ->add_action ( 'hcpp_invoke_plugin ' , [ $ this , 'hcpp_invoke_plugin ' ] );
69
69
$ hcpp ->add_action ( 'hcpp_list_web_xpath ' , [ $ this , 'hcpp_list_web_xpath ' ] );
70
+ $ hcpp ->add_action ( 'hcpp_add_webapp_xpath ' , [ $ this , 'hcpp_add_webapp_xpath ' ] );
70
71
$ hcpp ->add_action ( 'hcpp_rebooted ' , [ $ this , 'hcpp_rebooted ' ] );
71
72
$ hcpp ->add_action ( 'hcpp_runuser ' , [ $ this , 'hcpp_runuser ' ] );
72
73
$ hcpp ->add_action ( 'v_restart_proxy ' , [ $ this , 'v_restart_proxy ' ] );
@@ -79,7 +80,9 @@ public function __construct() {
79
80
*/
80
81
public function do_nginx_modified ( $ restart = false ) {
81
82
global $ hcpp ;
83
+ $ hcpp ->log ( "do_nginx_modified with restart: $ restart " );
82
84
$ lines = file ( "/tmp/nodeapp_nginx_modified " );
85
+ unlink ( "/tmp/nodeapp_nginx_modified " );
83
86
84
87
// Remove any duplicate lines
85
88
$ lines = array_unique ( $ lines );
@@ -90,10 +93,9 @@ public function do_nginx_modified( $restart = false ) {
90
93
$ domain = $ line [1 ];
91
94
$ conf_folders [] = trim ( "/home/ $ user/conf/web/ $ domain " );
92
95
}
93
- unlink ( "/tmp/nodeapp_nginx_modified " );
94
96
$ conf_folders = $ hcpp ->do_action ( "nodeapp_nginx_confs_written " , $ conf_folders );
95
97
if ( $ restart ) {
96
- $ hcpp ->run ( "v-restart-proxy nodeapp_nginx_modified " );
98
+ $ hcpp ->run ( "v-restart-proxy " );
97
99
}
98
100
}
99
101
@@ -256,6 +258,17 @@ public function get_pm2_log( $pm2_id ) {
256
258
return $ log ;
257
259
}
258
260
261
+ /**
262
+ * Restart proxy on modified nginx config files
263
+ */
264
+ public function hcpp_add_webapp_xpath ( $ xpath ) {
265
+ global $ hcpp ;
266
+ if ( file_exists ( "/tmp/nodeapp_nginx_modified " ) ) {
267
+ $ hcpp ->run ( "v-invoke-plugin nodeapp_nginx_modified " );
268
+ }
269
+ return $ xpath ;
270
+ }
271
+
259
272
/**
260
273
* Process the PM2 list command request
261
274
*/
@@ -335,13 +348,14 @@ public function hcpp_invoke_plugin( $args ) {
335
348
break ;
336
349
337
350
case 'nodeapp_nginx_modified ' :
338
- // shell_exec( __DIR__ . "/nodeapp_debounce.sh 2>&1 &" );
339
- $ this ->do_nginx_modified ( true );
351
+
352
+ // Debounce allows use to queue and delay under higher loads
353
+ shell_exec ( "nohup " . __DIR__ . "/nodeapp_debounce.sh > /dev/null 2>&1 & " );
340
354
break ;
341
355
342
356
case 'nodeapp_debounce ' :
343
357
if ( file_exists ( "/tmp/nodeapp_nginx_modified " ) ) {
344
- $ this ->do_nginx_modified ();
358
+ $ this ->do_nginx_modified ( true );
345
359
}
346
360
break ;
347
361
}
@@ -399,7 +413,7 @@ public function hcpp_rebooted() {
399
413
}
400
414
401
415
/**
402
- * Add the PM2 process list button to the HestiaCP UI
416
+ * Add the PM2 process list button to the HestiaCP UI, and restart proxy on modified nginx config files
403
417
*/
404
418
public function hcpp_list_web_xpath ( $ xpath ) {
405
419
@@ -601,8 +615,7 @@ public function v_delete_web_domain_backend( $args ) {
601
615
* Notify of any changes to the nginx config files
602
616
*/
603
617
public function v_restart_proxy ( $ args ) {
604
- if ( file_exists ( '/tmp/nodeapp_nginx_modified ' ) && ! isset ( $ args [0 ] ) ) {
605
- // shell_exec( __DIR__ . "/nodeapp_debounce.sh 2>&1 &" );
618
+ if ( file_exists ( '/tmp/nodeapp_nginx_modified ' ) ) {
606
619
$ this ->do_nginx_modified ( false );
607
620
}
608
621
return $ args ;
0 commit comments