Question

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!

Was it helpful?

Solution

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.

OTHER TIPS

You may consider to use ProcessBuilder which starts new OS process

Example:

Process p = new ProcessBuilder("myCommand", "myArg").start();
...
p.destroy();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top