Thanks for providing this useful info, helped me a lot.
This is what worked for me…
CommandLine command = new CommandLine(“cmd”);
command.addArgument("/c");
command.addArgument(“C://Users//…//Appium//node.exe”);
command.addArgument(“C://Users//…//Appium//node_modules//appium//bin//appium.js”);
command.addArgument("–address");
command.addArgument(“0.0.0.0”);
command.addArgument("–port");
command.addArgument(“4724”);
command.addArgument("–no-reset");
command.addArgument("–log");
command.addArgument(“C://Users//…//log//appiumLogs.txt”);
DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
DefaultExecutor executor = new DefaultExecutor();
executor.setExitValue(1);
executor.execute(command, resultHandler);
When i try to re-run the test, I see the error:
e[31merrore[39m: Couldn’t start Appium REST http interface listener. Requested port is already in use. Please make sure there’s no other instance of Appium running already.
I have to manually kill the process from Windows Task Manager and the re-run the test.
I thought about using it at first, but it turned out that it doesn’t destroy any spawned processes started by your application. You will end up with memory leaks and probably some errors when you try to open it again.
It perfectly closes child processes. As you can see, there is a process tree and when cmd.exe (with PID 6320) get closed - all child processes get closed as well
As I understood from the image you shared, you are starting a new JVM inside the original one. That’s why when you call the destroy function, the Java process and all of its child processes are destroyed. In my case, I was starting the Appium server from the original JVM which means that all of its spawned processes won’t be destroyed until the original Java JVM terminates.
P.S: I am running more than one server instance simultaneously and I can’t wait to clear up memory at the end when the JVM terminates.
Parent java process from the screenshot above - is IDE:-)
Just test run via “mvn test” command-line and got the same result: all processes closed perfectly!
Looks like it’s working with the destry method and there is no need to taskill the process … I am not sure why it wasn’t working with me when I tried it?
Anyway, I will give it another try. Thanks
When I tried to launch the server, I am geeting this below error:
" /Applications/Appium.app/Contents/Resources/node/bin/node: cannot execute binary file "
My code is this, Can anyone please help on this ?
CommandLine command = new CommandLine("/bin/sh");
command.addArgument("/Applications/Appium.app/Contents/Resources/node/bin/node");
command.addArgument("/Applications/Appium.app/Contents/Resources/node_modules/appium/bin/appium.js");
command.addArgument("–address");
command.addArgument(“127.0.0.1”);
command.addArgument("–port");
command.addArgument(“4723”);
command.addArgument("–no-reset");
command.addArgument("–log");
DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
DefaultExecutor executor = new DefaultExecutor();
executor.setExitValue(1);
By that, I didn’t mean adding it explicity … I meant to convert each line that uses addArgument function and make it take an argument and a false value .
But still getting the same error, do you think its because of any device incompatibility ?
Because all I get in searching internet about this is 32-bit vs 64-bit issues only.
OS X : Version 10.8.5
Appium version : 1.3.1 (Ophiuchus)
I am running below code pn my mac no error but appium is not started as well.
Where as if i involve from terminal this command : /Applications/Appium.app/Contents/Resources/node/bin/node /Applications/Appium.app/Contents/Resources/node_modules/appium/bin/appium.js --address 127.0.0.1 --port 4723 --no-reset --local-timezone