0

I made an app that use 6 process. There is no option for me to reduce this number.

I used to start those processed from java with some module I build around:

Runtime.getRuntime().exec() 

But it created a lot of troubles with errors handling. Terminating a process is not trivial.

So I moved to command line, and I wrote a batch script to start 6 command prompt(Windows consul window), now closing those also kill the process, so error handling become easier.

But it look very bad... Messy...

I guess this is not a common way to work, so my question is what is? How to manage multiple java processes with the next behaviors:

  • Process can crash
  • Optionally there is a dependency between processes, so if process A is terminated/crash, process B should be terminated as well, it's optional as it's easier for me to manage it this way, but I can code around it, so it's not mandatory.
  • Process can be force stopped with some timeout if it fails to complete it's task.
5
  • Please post minimal reproducible example. You say "Terminating a process is not trivial." Why not? What doesn't work with Process.destroy() ? What OS are you running this on? Commented Oct 6, 2016 at 7:56
  • @ErwinBolwidt You should google a little bit about Process.destroy(). It's not working well in java, regardless the OS. In my case I work with Windows, but I can move to different OS. Commented Oct 6, 2016 at 8:00
  • You're the one asking the question. If you can't use the most obvious thing you should show that research in your question to make it more useful. Commented Oct 6, 2016 at 8:07
  • @ErwinBolwidt In those comments you can find some of the problems with Process.destroy. I think most people aware of that. Commented Oct 6, 2016 at 8:12
  • Are you serious? These comments are jokes about skynet. The answer that they comment on says you should use Process.destroy(). It's not relevant in any case, the relevance to your question is: what problems do you have with Process.destroy() if any. Show that in your question. Commented Oct 6, 2016 at 8:21

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.