Detecting terminations from camunda cockpit

Hello community,

We have process than schematically looks like this:


Subprocesess 1 and 2 uses message nodes (waiting) to perfom lenghty matlab calculations (30-40 mins for happy day) and only one instance of main process can be running at any time (HW limitations - RAM).

Because of this, when client realizes incorrect process input (or matlab simply crashes), he kills stuck subprocess using cockip, causing main process state to be INTERNALLY_TERMINATED without executing the cleanup step.

My question is: is it possible to detect manual termination from main process, so the cleanup step can be executed? I was hoping using some event/boundary event, altough judging by documentation, this is not a case they have been designed for…

There is a way to do it manually from java - execute handler code of cleanup step before calling RuntimeService.deleteProcessInstance(…). But this would require redeployment of application and I was hoping to redeploy only the process definition, by redesigning process in smarter way.

Thans for any reply
forest