ericclemmons / grunt-express-server

Grunt task for running an Express Server that works great with LiveReload + Watch/Regarde

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Stopping server on error

DaftMonk opened this issue · comments

First of all, I want to thank you for the great work you've done on this grunt plugin.

I have livereload watching my server files. The problem is, if I introduce any error in the server code and save the file, the server reloads, throws an error, and then hangs. This is kind of annoying because then I have to close the command prompt out and CD back into the project folder to restart the server.

Is there a way to simply stop the server when an exception is thrown?

That's odd. I created this project because my server kept stopping whenever I introduced an error!

So, first, things first, can you post up your express portion of the grunt config? Second, are you exporting your server, as seen in server.js?

Here's the express block

express: {
  options: {
    port: process.env.PORT || 9000
  },
  dev: {
    options: {
      script: 'server.js'
    }
  },
  prod: {
    options: {
      script: 'server.js',
      node_env: 'production'
    }
  }
},

I'm not exporting the server, is that important? I just tried exporting it a moment ago, then tried to introduce an error, and it still hung up.

Ah, I see now. I'm having the same problem. I'll resolve it

Oh, God. I'm an idiot. I was treating grunt.util.spawn's callback as an error function, but in fact, it's just a next() call.

v0.4.7 should resolve this!

Awesome, that fixed it! Thanks for the quick response!