@@ -180,26 +180,42 @@ public boolean accept(File dir, String name) {
180180 /**
181181 * Flag to indicate if we should await plugin loading
182182 */
183- protected boolean awaitPlugins = true ;
184-
185- private static ExecutorService executor ;
183+ protected boolean awaitPlugins ;
186184
187185 /**
188186 * War deployer
189187 */
190188 private WarDeployer deployer ;
191189
190+ {
191+ // allow setting to true if we're running in Red5 Pro
192+ if (!awaitPlugins ) {
193+ try {
194+ awaitPlugins = Class .forName ("com.red5pro.plugin.Red5ProPlugin" ) != null ;
195+ log .debug ("Red5ProPlugin found, awaiting plugins" );
196+ } catch (ClassNotFoundException e ) {
197+ log .debug ("Red5ProPlugin not found, not awaiting plugins" );
198+ }
199+ }
200+ }
201+
202+ // TODO(paul) decouple this from Spring init bean use start method
192203 @ Override
193204 public void afterPropertiesSet () throws Exception {
194205 // if we are not awaiting plugins, start immediately
195206 if (awaitPlugins ) {
196207 log .info ("Awaiting plugin loading" );
197- executor = Executors .newSingleThreadExecutor ();
198- executor .submit (() -> {
199- final String oldName = Thread .currentThread ().getName ();
208+ Executors .newVirtualThreadPerTaskExecutor ().submit (() -> {
200209 Thread .currentThread ().setName ("TomcatLoader-delayed-start" );
201210 try {
202- while (!Red5 .isPluginsReady ()) {
211+ // wait for plugins to load but only up to 60 seconds
212+ long startTime = System .currentTimeMillis ();
213+ while (System .currentTimeMillis () - startTime < 60000L ) {
214+ // check if plugins are ready
215+ if (Red5 .isPluginsReady ()) {
216+ log .info ("Plugins are ready" );
217+ break ;
218+ }
203219 log .trace ("Waiting for plugins to load" );
204220 Thread .sleep (2000L );
205221 }
@@ -208,8 +224,6 @@ public void afterPropertiesSet() throws Exception {
208224 log .error ("Error starting Tomcat" , e );
209225 } catch (InterruptedException e ) {
210226 log .error ("Error waiting for plugins" , e );
211- } finally {
212- Thread .currentThread ().setName (oldName );
213227 }
214228 });
215229 } else {
@@ -940,9 +954,6 @@ public void destroy() throws Exception {
940954 deployer .stop ();
941955 deployer = null ;
942956 }
943- if (executor != null ) {
944- executor .shutdown ();
945- }
946957 // run through the applications and ensure that spring is told to commence shutdown / disposal
947958 AbstractApplicationContext absCtx = (AbstractApplicationContext ) LoaderBase .getApplicationContext ();
948959 if (absCtx != null ) {
0 commit comments