-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Milestone
Description
It would be great to have this feature in the next version.
Problem
I had this error when I launched multiple instances of different webapps:
Running "watch" task
Waiting...
Fatal error: Port 35729 is already in use by another process.
Solution
The solution is to use a random port number for watch and express' debug. I have only tested it under dev zone. The port number for debug is random, it's possible to have an error because Grunt initializes the same.
Install grunt-openport (https://github.com/shama/grunt-openport)
# npm install grunt-openport --save-dev
Add "dev_port" and "opts" under dev into Gruntfile.js
grunt.initConfig({
express: {
options: {
port: process.env.PORT || 9000
},
dev: {
options: {
script: 'server/app.js',
debug: true,
dev_port: true,
opts: ['--debug=<%= express.dev.options.dev_port %>']
And add all "openport" into the "serve" task:
grunt.registerTask('serve', function (target) {
if (target === 'dist') {
[...]
}
if (target === 'debug') {
[...]
}
grunt.task.run([
'openport:express.dev.options.dev_port:5860:5960',
'openport:watch.livereload.options.livereload:35729:36729',
'openport:watch.express.options.livereload:35729:36729',
'clean:server',
[...]
Update the file server/config/local.env.js with:
module.exports = {
DOMAIN: 'http://localhost:' + (process.env.PORT || 9000),
Now
# cd /my_project1 && PORT=9001 grunt serve
# cd /my_project2 && PORT=9002 grunt serve
Metadata
Metadata
Assignees
Labels
No labels