What is the best way to run multiple Almost Identical Java processes on the same Linux server?
Explanation of the environment:
We are running a set of Java processes that provide a calculation grid. The only difference between the processes, is the command line parameter that Identifies the node name. Something like:
(Process 1) Java -DNodeNumber=1 CalculationNode
(Process 2) Java -DNodeNumber=2 CalculationNode
(Process 3) Java -DNodeNumber=3 CalculationNode
(Process 4) Java -DNodeNumber=4 CalculationNode
The script that starts up a each process is relatively simple, but not trivial since there are around 15 other parameters that are needed – THEY ARE IDENTICAL FOR ALL PROCESSES
I need to be able to restart a process if it fails with the SAME NodeNumber parameter. In other words – if Node 3 fails, I need to restart it as Node 3.
Best Answer
I'd argue that if a process fails, you need to fix it in order to not fail anymore.
To do what you expect, something like this would suffice (untested, use at your own risk):
Each process has to finish with exit code zero in order to break the loop. Otherwise, it is restarted by the script.