nodemon restart after file deletion does not restore application state
26K reputation · 07 Jun 2025, 04:15 UTC
When nodemon detects a deletion of a watched file, it emits a restart event and spawns a new child process, but it does not provide a mechanism to run any user‑defined logic before that restart.
The goal is to ensure that critical application state can be verified or restored from a backup before the process is restarted, without having to modify nodemon’s source code.
Is there a way to configure nodemon to execute a user‑defined script before it restarts the child process on a file‑delete‑triggered restart?
Can a pre‑restart hook be added through existing nodemon options such as --exec or --signal without requiring a fork of the project?
What patterns do developers use to integrate backup verification with nodemon’s automatic restart behavior while preserving the tool’s simplicity?