Skip to content

Commit d19e894

Browse files
committed
fix debounce, nodeapp_nginx_modified event
1 parent 86772cb commit d19e894

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

nodeapp.php

+15-4
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,15 @@ public function generate_nginx_files( $nodeapp_folder, $inc_root = true ) {
310310
}
311311

312312
// Queue for single nginx files modified event
313-
file_put_contents("/tmp/nodeapp_nginx_modified", "$user $domain\n", FILE_APPEND);
313+
// Check if the file exists and doesn't already have $user $domain in it
314+
if ( file_exists( "/tmp/nodeapp_nginx_modified" ) ) {
315+
$content = file_get_contents( "/tmp/nodeapp_nginx_modified" );
316+
if ( strpos( $content, "$user $domain" ) === false ) {
317+
file_put_contents( "/tmp/nodeapp_nginx_modified", "$user $domain\n" );
318+
}
319+
}else{
320+
file_put_contents("/tmp/nodeapp_nginx_modified", "$user $domain\n", FILE_APPEND);
321+
}
314322
}
315323

316324
/**
@@ -409,8 +417,9 @@ public function hcpp_add_webapp_xpath( $xpath ) {
409417
*/
410418
public function hcpp_invoke_plugin( $args ) {
411419
global $hcpp;
412-
if ( count( $args ) < 2 ) return $args;
413-
$username = preg_replace( "/[^a-zA-Z0-9-_]+/", "", $args[1] ); // Sanitized username
420+
if ( isset( $args[1] ) ) {
421+
$username = preg_replace( "/[^a-zA-Z0-9-_]+/", "", $args[1] ); // Sanitized username
422+
}
414423
switch ( $args[0] ) {
415424
case 'nodeapp_get_versions':
416425
$hcpp->log( 'nodeapp_get_versions' );
@@ -493,7 +502,9 @@ public function hcpp_invoke_plugin( $args ) {
493502
case 'nodeapp_nginx_modified':
494503

495504
// Debounce allows use to queue and delay under higher loads
496-
shell_exec( "nohup " . __DIR__ . "/nodeapp_debounce.sh > /dev/null 2>&1 &" );
505+
$hcpp->log( $cmd );
506+
$cmd = "nohup " . __DIR__ . "/nodeapp_debounce.sh > /dev/null 2>&1 &";
507+
$hcpp->log( shell_exec( $cmd ) );
497508
break;
498509

499510
case 'nodeapp_debounce':

0 commit comments

Comments
 (0)