4 Replies Latest reply on Aug 22, 2016 8:26 AM by Sarah Qu

    Bootstrap Wildfly - shutdown the Wildfly server / kill JAVA process

    Sarah Qu Newbie

      Dear all,

       

      I saw the following project to start the server from a Main - Methode:

      https://github.com/jamezp/wildfly-bootstrap/blob/master/src/main/java/org/wildfly/bootstrap/Main.java

       

      Now I would like to stop also the server.

      How can I do this?

       

      I tried already this:

       

      
      
      
         
        public static void main(final String[] args) throws Exception {
      
      
             
       
      
      
         
          
       
      
      
         
      
      
       String currentPath = System.getProperty("user.dir");
      
      
         
      
      
       File currentFilePath = new File(currentPath).getParentFile();
      
      
         
      
      
       String pathForServer = currentFilePath.getAbsolutePath()
      
      
         
      
      
      
      
       + File.separatorChar + "service" + File.separatorChar
      
      
         
      
      
      
      
       + "server";
      
      
      
      
      
      
      
         
      
      
       final ServerBuilder builder = ServerBuilder.builder().setJbossHome(
      
      
         
      
      
      
      
       Paths.get(pathForServer));
      
      
         
      
      
        final Server server = builder.build();
      
      
      
      
      
      
      
      
         
           
      server.start();
      
      
      
      
      
      
      
         
           
      while (server.getState() == State.STARTED) {
      
      
         
               
      TimeUnit.SECONDS.sleep(40);
      
      
         
           
      }
      
      
         
          
       
      
      
         
           
      server.shutdown();
      
      
         
       }
      
      
      
      

       

      But this will not kill the JAVA process. How can I do this?