You can probably clean this up a bit if you use pretest, test, and posttest to handle startup/shutdown of your server, see https://npmjs.org/doc/misc/npm-scripts.html