I'm planning to implement checkpointing to react to AWS Spot interruptions (which send a `SIGTERM`) in a Symfony application. I already implemented a listener for `console.signal` to log occurrences of such events, and `SignalableCommandInterface` on a specific Symfony command to log progress at interruption time for that command, and I was wondering if there was a library I should know about or a blog post I should read before implementing the checkpoint logic itself. What do you recommend? 🙂
TIL
has an xkcd comic inside its manual: https://www.php.net/manual/en/control-structures.goto.php
I'm looking at this page because a silly part of my brain is wondering if "starting over" might be a legitimate use case for `goto` 😅
Consider the following piece of code
```
public function __invoke()
{
a();
b();
c();
d();
e();
f();
g();
}
```
You know the cronjob has been interrupted while in `c()`. How would you go about starting over from `c()` ?
@greg0ire using the second way, your invoke method should be :
```
public function __invoke($step = 1) {
while(!$isFinished) {
$currentStep = 'step_' . $step;
if (function_exists($$currentStep)) {
$currentStep();
$step++;
} else {
$isFinished = true;
}
}
}
```
that way if I want to declare a new step later I only need to declare a new function/method with the correct name.