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

Start event script also runs on restart #1675

Closed
breytex opened this issue Feb 14, 2020 · 1 comment
Closed

Start event script also runs on restart #1675

breytex opened this issue Feb 14, 2020 · 1 comment

Comments

@breytex
Copy link

breytex commented Feb 14, 2020

  • nodemon -v:
    2.0.2
  • node -v:
    v10.18.1
  • Operating system/terminal environment:
    MacOS high sierra / iterm2
  • Using Docker? What image:
    docker 10-alpine
  • Command you ran:
    nodemon --inspect=0.0.0.0 --exec node src/index.js
    with
{
  "verbose": false,
  "ignore": ["generator/temp/**", "public/**"],
  "events": {
    "start": "node src/script.js"
  }
}

Expected behaviour

src/script.js is only executed once at startup and not when the I change a file and nodemon restarts the main app (src/index.js).

Actual behaviour

src/script.js is executed on every restart

Steps to reproduce

Create three files with a console log of its filename:

  • index.js
  • start.js
  • restart.js

Create nodemon.json:

{
    "verbose": true,
    "events": {
        "start": "node start.js",
        "restart": "node restart.js"
    }
}

Run

nodemon --exec node index.js

Hello everybody :-)
Is this intended behavior?
As I see it, right now it's not possible to run a script ONLY on startup.
With using the restart event, its possible to only use a script on restart, so I would understand the start event to not also cover restarts, but exactly that is the case (at least in my setup / versions).

Any help appreciated.
Thanks!

@breytex breytex changed the title Start event script als runs on restart Start event script also runs on restart Feb 14, 2020
@remy
Copy link
Owner

remy commented Feb 17, 2020

start refers to the subprocess starting, not nodemon starting.

@remy remy closed this as completed Feb 17, 2020
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