문제

I'm new to headless applications and, as the title describes, I want to know what methods are there to terminate a headless application? While on the topic, how does one normally deploy the application?

Thank you!

도움이 되었습니까?

해결책

Basic solution principle: On the server side (the headless app, I call it the service) have a ServerSocket open that listens to a certain port. From the outside, connect to that ServerSocket and send a certain message. When the server application gets the connection request, it can act upont it.

Hints: However, be certain that you use something like a secret message or some other authentication method like signatures and SSL, because else everyone who knows the servers port could close your application.

BTW This same solution principle can also be used to pass new parameters to an already running application, like a double-click on some audio file in you browser will play the new title in the current audio player and not in a new instance. (the new instance actually gets started but sends the new file/title to the older instance, which catches it and switches to that new song)

Additional: When you have another way of sending data to the app, as in web pages where you can POST/GET data, you can also parse that input for a specific message.

다른 팁

You may consider to use ProcessBuilder which starts new OS process

Example:

Process p = new ProcessBuilder("myCommand", "myArg").start();
...
p.destroy();
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top