@@ -19,9 +19,8 @@ public function __construct() {
1919 $ hcpp ->vitepress = $ this ;
2020 $ hcpp ->add_action ( 'hcpp_invoke_plugin ' , [ $ this , 'setup ' ] );
2121 $ hcpp ->add_action ( 'hcpp_render_body ' , [ $ this , 'hcpp_render_body ' ] );
22- $ hcpp ->add_action ( 'hcpp_nginx_reload ' , [ $ this , 'hcpp_nginx_reload ' ] );
23- $ hcpp ->add_action ( 'priv_unsuspend_web_domain ' , [ $ this , 'priv_unsuspend_domain ' ] ); // Bulk unsuspend domains only throws this event
24- $ hcpp ->add_action ( 'priv_unsuspend_domain ' , [ $ this , 'priv_unsuspend_domain ' ] ); // Individually unsuspend domain only throws this event
22+ $ hcpp ->add_action ( 'hcpp_nginx_reload ' , [ $ this , 'hcpp_nginx_reload ' ], 20 );
23+ $ hcpp ->add_action ( 'nodeapp_ports_allocated ' , [ $ this , 'nodeapp_ports_allocated ' ] ); // Add vitepress on copy
2524 }
2625
2726 /**
@@ -32,7 +31,6 @@ public function hcpp_nginx_reload( $cmd ) {
3231 if ( ! file_exists ( '/tmp/vitepress_domains ' ) ) return $ cmd ;
3332 $ hcpp ->log ('FOUND vitepress_domains ' );
3433 $ vitepress_domains = json_decode ( file_get_contents ( '/tmp/vitepress_domains ' ), true );
35- unlink ( '/tmp/vitepress_domains ' );
3634 $ hcpp ->log ( $ vitepress_domains );
3735 foreach ( $ vitepress_domains as $ vitepress_domain ) {
3836 $ user = $ vitepress_domain ['user ' ];
@@ -67,19 +65,23 @@ public function hcpp_nginx_reload( $cmd ) {
6765 $ hcpp ->log ("Could not find $ nginx_ssl_conf for VitePress " );
6866 }
6967 }
68+ $ cmd = str_replace ( 'sleep 5 ' , 'sleep 5 && rm /tmp/vitepress_domains ' , $ cmd );
7069 return $ cmd ;
7170 }
7271
7372 /**
74- * Add flag to add .vitepress to nginx.conf and nginx.ssl.conf on unsuspend
73+ * Add flag to add .vitepress to nginx.conf and nginx.ssl.conf on port allocation
7574 */
76- public function priv_unsuspend_domain ( $ args ) {
75+ public function nodeapp_ports_allocated ( $ args ) {
7776 global $ hcpp ;
78- $ user = $ args [0 ];
79- $ domain = $ args [1 ];
77+ $ user = $ args [' user ' ];
78+ $ domain = $ args [' domain ' ];
8079
8180 // Continue only if vitepress_port on domain
82- if ( $ hcpp ->get_port ( 'vitepress_port ' , $ user , $ domain ) == 0 ) return $ args ;
81+ if ( $ hcpp ->get_port ( 'vitepress_port ' , $ user , $ domain ) == 0 ) {
82+ $ hcpp ->log ( "No vitepress_port for $ user $ domain " );
83+ return $ args ;
84+ }
8385
8486 // Flag to add .vitepress to nginx.conf and nginx.ssl.conf on hcpp_nginx_reload
8587 if ( file_exists ( '/tmp/vitepress_domains ' ) ) {
@@ -128,7 +130,7 @@ public function setup( $args ) {
128130 $ hcpp ->nodeapp ->allocate_ports ( $ nodeapp_folder );
129131
130132 // Flag to add .vitepress to nginx.conf and nginx.ssl.conf on hcpp_nginx_reload
131- $ this ->priv_unsuspend_domain ( [ $ user , $ domain ] );
133+ $ this ->nodeapp_ports_allocated ( [ ' user ' => $ user , ' domain ' => $ domain ] );
132134
133135 // Update proxy and restart nginx
134136 if ( $ nodeapp_folder . '/ ' == $ vitepress_folder ) {
0 commit comments