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? 🙂

To clarify, I need to implement this in a very long cronjob, and by "checkpointing" I mean saving progress, and starting over from where I left off during the next invocation of the command.

TIL :php: has an xkcd comic inside its manual: php.net/manual/en/control-stru

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 It seems the goto argument cannot be a variable, so you would need something quite ugly to prepare for this (I tried and couldn't use a goto $step;

public function __invoke(string $step)
{
switch ($step) {
case "a":
goto a;
break;
case "b":
goto b;
break;
case "c":
goto c;
break;
case "d":
goto d;
break;
case "e":
goto e;
break;
case "f":
goto f;
break;
case "g":
goto g;
break;
}
a:
a();

b:
b();

c:
c();

d:
d();

e:
e();

f:
f();

g:
g();
}


@MarcBrillault I think removing the `break` statements as proposed by @Vimar should result in something nicer :)

Suivre

@MarcBrillault @greg0ire By the way I don't want to be eaten by a raptor 😂

Inscrivez-vous pour prendre part à la conversation
techlover

Technology lovers, here we are — (development, digital artwork, science…)