pup icon indicating copy to clipboard operation
pup copied to clipboard

Restart on crash?

Open nCrafts opened this issue 2 years ago • 5 comments

I am trying to understand better how crash works. If my service crashes owing to an uncaught error is there a way to restart it? I simulated this scenario using

throw new Error("test error");

And setting restart to "always" but it only restarts on file changes.

Any tips? Thanks!

nCrafts avatar Oct 20 '23 17:10 nCrafts

:wave:

This is a minimal example to auto start a process and restart it on crash - does this work @nCrafts ?:

https://github.com/Hexagon/pup/blob/main/docs/src/examples/minimal/pup.jsonc

{
  "processes": [
    {
      "id": "forever",
      "cmd": "deno run --allow-env server.js",
      "autostart": true,
      "restart": "always"
    }
  ]
}

Hexagon avatar Oct 20 '23 17:10 Hexagon

I see. That works. If I have --watch in the cmd it fails, but if I remove that and use the built in pup's watch it works as expected. Is that expected?

nCrafts avatar Oct 20 '23 19:10 nCrafts

Nice!

I have not considered Deno's built in watcher, will have to have a look at that. Let's leave this issue open until then 👍

Hexagon avatar Oct 20 '23 19:10 Hexagon

Thank you so much! Also I noticed that when I am running it on a mac with the watch configuration enabled I can't seem to exit using ctrl + c. It does terminate the processes but the watcher keeps running. Any tips?

nCrafts avatar Oct 20 '23 19:10 nCrafts

Open a separate issue describing that, and we'll figure it out from there. I have no mac at hand, but signals are handled specifically so it's most probably a Pup issue.

Hexagon avatar Oct 20 '23 19:10 Hexagon