gruntjs / grunt-contrib-connect

Start a static web server.
http://gruntjs.com
MIT License
714 stars 146 forks source link

Possibility to reload server #231

Open codekraft-studio opened 7 years ago

codekraft-studio commented 7 years ago

I'm using connect with socketio and I would like to reload the server and then rerun the onCreateServer function.

Something like this:

watch: {
   serverApi: {
       options: {
        livereload: true
      },
      files: ['bin/www.js']
   }
}

where bin/www.js is a file with a running socket server used like this:

connect: {
      options: {
        port: 9000,
        hostname: 'localhost',
        livereload: 35729,
        debug: true
      },
      livereload: {
        onCreateServer: function(server, connect, options) {
            var socketServer = require('./bin/www');
            socketServer(server);
        }
      }
}

So basically when I change the file that handle the socket server, it reload the connect server, so I don't have to do it manually.

I know that livereload is supposed to work on the browser side, but i'm suggesting something similar to reload the connect sever.

Related to: #117 #83 #217

Many thanks in advance.