Difference between stopping the Appium server and killing the Appium server

I have used the following code to stop appium process.But actually it is killing the process.

public static void stopAppiumServer() throws IOException {
CommandLine command = new CommandLine(“cmd”);
command.addArgument("/c");
command.addArgument(“Taskkill /F /IM node.exe”);

    DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();  
    DefaultExecutor executor = new DefaultExecutor();  
    executor.setExitValue(1);  
    executor.execute(command, resultHandler);
}

How to stop the server through code

@Hassan_Radi Suggestions Please…

@SergeyTichomirov
@0x1mason
Any comments?

@Donald any suggestions?

Hi Ashok,

You can use sendsignal to send CTRL+C signal to your appium server.
Usage is sendsignal.exe processID. You can save PID for appium server when starting it or yopu can filter it from tasklist | grep node.exe (in case of only one node process). I don’t know if this is what you need , but CTRL+C is the option I use for stopping server clean way.

Thanks,
Donald

Hi Donald,
Thank you very much for the information.

In my case I run two programs,

One is for ios app and another is for apk app.
The ios port address is 4723 and the apk port address is 4724.

I want to stop the particular port address not both.The code I have used is killing both the process.

I have gone through the topic sendsignal but still not getting a clear view.

Hi Ashok,

In my case I started two instances from terminal and I can list both of them with tasklist filter.


Now just pass the process ID of appium server you wanna kill to sendsignal utility for example sendsignal.exe 416 to kill second instance of appium server.

Catch here is, you have to save the process ID in your java program, when you are initiating it.

Thanks,
Donald

Hi Donald,

I started the appium servers in two different ports. When I try with tasklist filter in command prompt.
I’m facing this issue.

Also how can I catch the process ID ?