Skip to content
This repository

Support Graceful Restarts #2716

Open
wants to merge 1 commit into from

6 participants

Bryant Williams Florian Margaine Domenic Denicola Luke Arduini Elias G. Schnéevoigt Tim Oxley
Bryant Williams

npm/npm#1999

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.

Florian Margaine
Ralt commented March 16, 2013

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.

Domenic Denicola
Collaborator

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

Luke Arduini
Collaborator
luk- commented March 18, 2013

LGTM

Elias G. Schnéevoigt

Why isn't this merged?

Luke Arduini
Collaborator

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.

Tim Oxley
Collaborator

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

#4430

Elias G. Schnéevoigt

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:)

Domenic Denicola
Collaborator

This needs a test before it can be merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Aug 13, 2012
Bryant Williams if restart script is provided, don't run stop and start 85eb9d6
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 1 addition and 2 deletions. Show diff stats Hide diff stats

  1. 3  lib/run-script.js
3  lib/run-script.js
@@ -80,9 +80,8 @@ function runScript (args, cb) {
80 80
 function run (pkg, wd, cmd, cb) {
81 81
   var cmds = []
82 82
   if (!pkg.scripts) pkg.scripts = {}
83  
-  if (cmd === "restart") {
  83
+  if (!pkg.scripts.restart && cmd === "restart") {
84 84
     cmds = ["prestop","stop","poststop"
85  
-           ,"restart"
86 85
            ,"prestart","start","poststart"]
87 86
   } else {
88 87
     cmds = [cmd]
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.