Skip to content

Commit 22c200c

Browse files
committed
update
1 parent 8226b37 commit 22c200c

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

nodeapp.php

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public function __construct() {
6767
$hcpp->add_action( 'v_unsuspend_domain', [ $this, 'v_unsuspend_domain' ] ); // Individually unsuspend domain only throws this event
6868
$hcpp->add_action( 'hcpp_invoke_plugin', [ $this, 'hcpp_invoke_plugin' ] );
6969
$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' ] );
7071
$hcpp->add_action( 'hcpp_rebooted', [ $this, 'hcpp_rebooted' ] );
7172
$hcpp->add_action( 'hcpp_runuser', [ $this, 'hcpp_runuser' ] );
7273
$hcpp->add_action( 'v_restart_proxy', [ $this, 'v_restart_proxy'] );
@@ -79,7 +80,9 @@ public function __construct() {
7980
*/
8081
public function do_nginx_modified( $restart = false ) {
8182
global $hcpp;
83+
$hcpp->log( "do_nginx_modified with restart: $restart" );
8284
$lines = file( "/tmp/nodeapp_nginx_modified" );
85+
unlink( "/tmp/nodeapp_nginx_modified" );
8386

8487
// Remove any duplicate lines
8588
$lines = array_unique( $lines );
@@ -90,10 +93,9 @@ public function do_nginx_modified( $restart = false ) {
9093
$domain = $line[1];
9194
$conf_folders[] = trim( "/home/$user/conf/web/$domain" );
9295
}
93-
unlink( "/tmp/nodeapp_nginx_modified" );
9496
$conf_folders = $hcpp->do_action( "nodeapp_nginx_confs_written", $conf_folders );
9597
if ( $restart ) {
96-
$hcpp->run( "v-restart-proxy nodeapp_nginx_modified" );
98+
$hcpp->run( "v-restart-proxy" );
9799
}
98100
}
99101

@@ -256,6 +258,17 @@ public function get_pm2_log( $pm2_id ) {
256258
return $log;
257259
}
258260

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+
259272
/**
260273
* Process the PM2 list command request
261274
*/
@@ -335,13 +348,14 @@ public function hcpp_invoke_plugin( $args ) {
335348
break;
336349

337350
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 &" );
340354
break;
341355

342356
case 'nodeapp_debounce':
343357
if ( file_exists( "/tmp/nodeapp_nginx_modified" ) ) {
344-
$this->do_nginx_modified();
358+
$this->do_nginx_modified( true );
345359
}
346360
break;
347361
}
@@ -399,7 +413,7 @@ public function hcpp_rebooted() {
399413
}
400414

401415
/**
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
403417
*/
404418
public function hcpp_list_web_xpath( $xpath ) {
405419

@@ -601,8 +615,7 @@ public function v_delete_web_domain_backend( $args ) {
601615
* Notify of any changes to the nginx config files
602616
*/
603617
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' ) ) {
606619
$this->do_nginx_modified( false );
607620
}
608621
return $args;

0 commit comments

Comments
 (0)