Hexagon / pup

Universal process manager built in Deno
https://pup.56k.guru
MIT License
160 stars 5 forks source link

Restart on crash? #44

Open nCrafts opened 1 year ago

nCrafts commented 1 year ago

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!

Hexagon commented 1 year ago

: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"
    }
  ]
}
nCrafts commented 1 year ago

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?

Hexagon commented 1 year ago

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 👍

nCrafts commented 1 year ago

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?

Hexagon commented 1 year ago

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.