[ 
https://issues.apache.org/jira/browse/ARTEMIS-3808?focusedWorklogId=771926&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-771926
 ]

ASF GitHub Bot logged work on ARTEMIS-3808:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 18/May/22 14:51
            Start Date: 18/May/22 14:51
    Worklog Time Spent: 10m 
      Work Description: jbertram commented on code in PR #4061:
URL: https://github.com/apache/activemq-artemis/pull/4061#discussion_r875998489


##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java:
##########
@@ -4479,5 +4488,71 @@ public void replay(String startScan, String endScan, 
String address, String targ
 
       server.replay(startScanDate, endScanDate, address, target, filter);
    }
+
+   @Override
+   public void stopEmbeddedWebServer() throws Exception {
+      synchronized (embeddedWebServerLock) {
+         getEmbeddedWebServerComponent().stop(true);
+      }
+   }
+
+   @Override
+   public void startEmbeddedWebServer() throws Exception {
+      synchronized (embeddedWebServerLock) {
+         getEmbeddedWebServerComponent().start();
+      }
+   }
+
+   @Override
+   public void restartEmbeddedWebServer() throws Exception {
+      
restartEmbeddedWebServer(ActiveMQDefaultConfiguration.getDefaultEmbeddedWebServerRestartTimeout());
+   }
+
+   @Override
+   public void restartEmbeddedWebServer(long timeout) throws Exception {
+      final CountDownLatch latch = new CountDownLatch(1);
+      final AtomicReference<Exception> exception = new AtomicReference<>();
+      /*
+       * This needs to be run in its own thread managed by the broker because 
if it is run on a thread managed by Jetty
+       * (e.g. if it is invoked from the web console) then the thread will die 
before Jetty can be restarted.
+       */
+      server.getThreadPool().execute(() -> {
+         try {
+            synchronized (embeddedWebServerLock) {
+               stopEmbeddedWebServer();
+               startEmbeddedWebServer();
+            }
+         } catch (Exception e) {
+            exception.set(e);
+         } finally {
+            latch.countDown();
+         }
+      });
+      boolean result = !latch.await(timeout, TimeUnit.MILLISECONDS);
+      if (result || exception.get() != null) {
+         throw 
ActiveMQMessageBundle.BUNDLE.embeddedWebServerNotRestarted(timeout, 
exception.get());
+      }

Review Comment:
   Yes, that would be more clear.





Issue Time Tracking
-------------------

    Worklog Id:     (was: 771926)
    Time Spent: 5h 40m  (was: 5.5h)

> Support starting/stopping the embedded web server via mangement
> ---------------------------------------------------------------
>
>                 Key: ARTEMIS-3808
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-3808
>             Project: ActiveMQ Artemis
>          Issue Type: Improvement
>            Reporter: Justin Bertram
>            Assignee: Justin Bertram
>            Priority: Major
>          Time Spent: 5h 40m
>  Remaining Estimate: 0h
>
> It would be useful to be able to cycle the embedded web server if, for 
> example, one needed to renew the SSL certificates.



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to