I am developing a workflow, which triggers independent code wich must be stopped in case of an error, stop signal, or temporal being down. Therefore I came up with the following steps:
- 1, run a setup activity on HostA
- 2, run an activity that initiates independent code on HostA that runs in a loop (ideally forever without intervention/error),
- 3, update a TTL for step 2 every few seconds, ensuring code termination in case of temporal being unavailable
- 4, stop the code on HostA by setting a flag (via cancellation, signals, or if an error occurs)
My main problem is, that I need to be sure that steps 1 to 4 are executed by the same running process/binary to guarantee termination.
I was thinking, that I could simply use local activities, which would work as long as there is only one host.
Session workers would fix the problem, but I am unsure if they can be combined - is this possible, and will work as expected?
Regarding -4, I am aware that cancellation only works with heartbeats, which are not enabled for local activities, but this is my least concern.