modules/tests/test-integration/src/test/java/org/ballerinalang/test/context/ServerInstance.java
/**
     * Stop the server instance which is started by start method.
     *
     * @throws InterruptedException
     */
Stop the server instance which is started by start method.
Stop the server instance which is started by start method .
@Override
    public void stop() throws InterruptedException {
        log.info("Stopping server..");
        if (process != null) {
            String pid;
            try {
                pid = getServerPID();
                if (Utils.getOSName().toLowerCase().contains("windows")) {
                    Process killServer = Runtime.getRuntime().exec("TASKKILL -F /PID " + pid);
                    log.info(readProcessInputStream(killServer.getInputStream()));
                    killServer.waitFor(15, TimeUnit.SECONDS);
                    killServer.destroy();
                } else {
                    Process killServer = Runtime.getRuntime().exec("kill -9 " + pid);
                    killServer.waitFor(15, TimeUnit.SECONDS);
                    killServer.destroy();
                }
            } catch (IOException e) {
                log.error("Error while getting the server process id", e);
            }
            process.destroy();
            serverInfoLogReader.stop();
            serverErrorLogReader.stop();
            process = null;
            Utils.waitForPortToClosed(httpServerPort, 30000);
            log.info("Server Stopped Successfully");
        }
    }
@ Override public void stop ( ) throws InterruptedException { log . info ( "Stopping server.." ) ; if ( process != null ) { String pid ; try { pid = getServerPID ( ) ; if ( Utils . getOSName ( ) . toLowerCase ( ) . contains ( "windows" ) ) { Process killServer = Runtime . getRuntime ( ) . exec ( "TASKKILL -F /PID " + pid ) ; log . info ( readProcessInputStream ( killServer . getInputStream ( ) ) ) ; killServer . waitFor ( 15 , TimeUnit . SECONDS ) ; killServer . destroy ( ) ; } else { Process killServer = Runtime . getRuntime ( ) . exec ( "kill -9 " + pid ) ; killServer . waitFor ( 15 , TimeUnit . SECONDS ) ; killServer . destroy ( ) ; } } catch ( IOException e ) { log . error ( "Error while getting the server process id" , e ) ; } process . destroy ( ) ; serverInfoLogReader . stop ( ) ; serverErrorLogReader . stop ( ) ; process = null ; Utils . waitForPortToClosed ( httpServerPort , 30000 ) ; log . info ( "Server Stopped Successfully" ) ; } }
Stop the server instance which is started by start method.
Stop the server instance which is started by start method .
//wait until port to close