title: gulp-livereload reloading before server process finishes restarting
body: <p>I'm configuring my <a href="http://gulpjs.com/" rel="nofollow noreferrer">gulp.js</a> gulpfile to watch my directory for file changes, and 1) reload my express server and 2) issue a livereload "change" event so that my browser (with the LiveReload chrome extension) will reload the page that I'm developing.</p>
  
  <p>Here's my gulpfile:</p>
  
  <pre><code>var gulp = require('gulp')
    , nodemon = require('gulp-nodemon')
    , livereload = require('gulp-livereload');
  
  gulp.task('startReloadServer', function() {
    livereload.listen();
  });
  
  gulp.task('demon', function () {
    nodemon({
      script: 'server.js',
      ext: 'js html',
      env: {
        'NODE_ENV': 'development'
      }
    })
      .on('start', ['startReloadServer'])
      .on('restart', function () {
        console.log('restarted!');
        livereload.changed();
      });
  });
  
  gulp.task('default', ['demon']);
  </code></pre>
  
  <p>Yet when I make a change to one of my view (.html) files, my browser reloads the page before the node server process has had an opportunity to come back online:</p>
  
  <p><img src="https://i.stack.imgur.com/e7Xvq.png" alt="failed browser request"></p>
  
  <p>How do I alter my gulpfile to have the livereload.changed() event be issued <em>after</em> nodemon is ready to receive requests?</p>