Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restart on crash? #44

Open
nCrafts opened this issue Oct 20, 2023 · 5 comments
Open

Restart on crash? #44

nCrafts opened this issue Oct 20, 2023 · 5 comments

Comments

@nCrafts
Copy link

nCrafts commented Oct 20, 2023

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
Copy link
Owner

Hexagon commented Oct 20, 2023

👋

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
Copy link
Author

nCrafts commented Oct 20, 2023

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
Copy link
Owner

Hexagon commented Oct 20, 2023

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
Copy link
Author

nCrafts commented Oct 20, 2023

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
Copy link
Owner

Hexagon commented Oct 20, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants