Skip to content


Support Graceful Restarts #2716

wants to merge 1 commit into from

7 participants



npm restart currently runs prestop, stop, poststop, restart, prestart, start, poststart. According to the docs, and the original intention of the feature, a restart script should be able to be provided so the application can choose to restart their service gracefully (see npm/npm#184) instead of issueing a full stop/start.

Note: npm restart will run the stop and start scripts if no restart script is provided.

A full stop/start should only happen if a restart script is not provided.


Looks like the commit log should be "Don't run restart if it doesn't exist", shouldn't it? I'm confused between your description and the code in the commit.

npm member

No, the commit message makes sense. LGTM, @isaacs?




Why isn't this merged?


I think we can probably merge this if someone wants to update the docs for it as well. If not, I can tomorrow or sometime this week.

npm member

@scien want to add "npm restart will run the stop and start scripts if no restart script is provided." to the docs?



The docs says:
This runs a package's "restart" script, if one was provided. Otherwise it runs package's "stop" script, if one was provided, and then the "start" script.
It seems to sufficiently describe the functionality, if this pull request gets merged?

I think this should just be merged already:)

npm member

This needs a test before it can be merged.

@domenic domenic added the needs-tests label

This has been waiting for a test without getting one for over a year. Closing as abandoned. Thanks for taking the time to put it together, @scien, and sorry we let it languish for so long without providing feedback. If you want to take another stab at this, a new version, with tests, would be welcome.

@othiym23 othiym23 closed this
@othiym23 othiym23 removed the review label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 14, 2012
  1. @scien
Showing with 1 addition and 2 deletions.
  1. +1 −2 lib/run-script.js
3 lib/run-script.js
@@ -80,9 +80,8 @@ function runScript (args, cb) {
function run (pkg, wd, cmd, cb) {
var cmds = []
if (!pkg.scripts) pkg.scripts = {}
- if (cmd === "restart") {
+ if (!pkg.scripts.restart && cmd === "restart") {
cmds = ["prestop","stop","poststop"
- ,"restart"
} else {
cmds = [cmd]
Something went wrong with that request. Please try again.