aetheon/grunt-http-server — pull request #4 by bryanisimo (2014-04-14 18:13:17+00:00)
Title: Dynamic port

Maybe if you use multiple projects you want to use dynamic ports, maybe this works:

module.exports = function( grunt ) {

var server_port_number = 9000;
grunt.initConfig({
'http-server': {
'dev': {
port: function(){ return server_port_number; },
...
}
}

grunt.registerTask('server', function( port ) {
server_port_number = port == null ? 9000 : port;
grunt.task.run('http-server:dev');
});

To assign a port, we just exec:
grunt server:9090