Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check port #345

Merged
merged 2 commits into from
Jul 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions lib/utils/serve-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,25 @@ module.exports = (program) => {

server.start((e) => {
if (e) {
console.log(e)
if (e.code === 'EADDRINUSE') {
const finder = require('process-finder')
finder.find({ elevate: false, port: program.port }, (startErr, pids) => {
const msg =
`We were unable to start Gatsby on port ${program.port} as there's already a process
listening on that port (PID: ${pids[0]}). You can either use a different port
(e.g. gatsby serve-build --port ${parseInt(program.port, 10) + 1}) or stop the process
already listening on your desired port.`
console.log(msg)
process.exit()
})
} else {
console.log(e)
}
} else {
if (program.open) {
opn(server.info.uri)
}
console.log('Listening at:', server.info.uri)
}
if (program.open) {
opn(server.info.uri)
}
return console.log('Listening at:', server.info.uri)
})
}
46 changes: 23 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
},
"dependencies": {
"async": "^1.2.1",
"babel-core": "^6.9.1",
"babel-core": "^6.10.4",
"babel-loader": "^6.2.4",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-transform-object-assign": "^6.8.0",
"babel-preset-es2015": "^6.9.0",
"babel-preset-react": "^6.5.0",
"babel-preset-react": "^6.11.1",
"babel-preset-react-hmre": "^1.1.1",
"babel-preset-stage-0": "^6.5.0",
"boom": "^2.7.2",
Expand All @@ -27,13 +27,13 @@
"css-loader": "^0.23.1",
"debug": "^2.2.0",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.8.5",
"file-loader": "^0.9.0",
"front-matter": "^2.1.0",
"fs-extra": "^0.30.0",
"glob": "^7.0.4",
"glob": "^7.0.5",
"hapi": "^8.5.1",
"hapi-webpack-plugin": "^1.3.0",
"highlight.js": "^9.4.0",
"highlight.js": "^9.5.0",
"history": "^2.1.2",
"html-frontmatter": "^1.6.0",
"invariant": "^2.2.1",
Expand All @@ -43,28 +43,28 @@
"less-loader": "^2.2.0",
"loader-utils": "^0.2.15",
"lodash": "^4.13.1",
"markdown-it": "^6.0.5",
"moment": "^2.11.2",
"markdown-it": "^7.0.0",
"moment": "^2.14.1",
"negotiator": "^0.6.1",
"node-cjsx": "^1.0.0",
"node-libs-browser": "^1.0.0",
"node-sass": "^3.7.0",
"node-sass": "^3.8.0",
"null-loader": "^0.1.1",
"object-assign": "^4.1.0",
"opn": "^4.0.2",
"parse-filepath": "^1.0.1",
"postcss-browser-reporter": "^0.5.0",
"postcss-cssnext": "^2.6.0",
"postcss-cssnext": "^2.7.0",
"postcss-import": "^8.1.2",
"postcss-loader": "^0.9.1",
"postcss-reporter": "^1.3.3",
"postcss-reporter": "^1.4.1",
"process-finder": "^1.0.0",
"raw-loader": "^0.5.1",
"react": "^15.1.0",
"react": "^15.2.0",
"react-document-title": "^2.0.1",
"react-dom": "^15.1.0",
"react-dom": "^15.2.0",
"react-hot-loader": "^1.3.0",
"react-router": "^2.4.1",
"react-router": "^2.5.2",
"react-router-scroll": "^0.2.0",
"sass-loader": "^3.1.2",
"slash": "^1.0.0",
Expand All @@ -73,35 +73,35 @@
"toml": "^2.2.2",
"toml-loader": "^1.0.0",
"tracer": "^0.8.3",
"typography": "^0.9.1",
"typography": "^0.10.5",
"url-loader": "^0.5.7",
"webpack": "^1.13.1",
"webpack-configurator": "^0.3.0",
"webpack-hot-middleware": "^2.7.1",
"webpack-hot-middleware": "^2.12.0",
"webpack-require": "0.0.16",
"yaml-loader": "^0.2.0"
},
"devDependencies": {
"ava": "^0.15.2",
"ava-http": "^0.2.1",
"babel-cli": "^6.9.0",
"babel-eslint": "^6.0.2",
"babel-eslint": "^6.1.0",
"babel-plugin-transform-flow-strip-types": "^6.8.0",
"babel-register": "^6.9.0",
"bluebird": "^3.4.0",
"bluebird": "^3.4.1",
"cheerio": "^0.20.0",
"eslint": "^2.11.1",
"eslint-config-airbnb": "^9.0.1",
"eslint-plugin-ava": "^2.5.0",
"eslint-plugin-flow-vars": "^0.4.0",
"eslint-plugin-flowtype": "^2.2.7",
"eslint-plugin-import": "^1.8.1",
"eslint-plugin-flowtype": "^2.3.0",
"eslint-plugin-import": "^1.10.2",
"eslint-plugin-jsx-a11y": "^1.5.3",
"eslint-plugin-react": "^5.1.1",
"flow-bin": "^0.27.0",
"eslint-plugin-react": "^5.2.2",
"flow-bin": "^0.28.0",
"iflow-debug": "^1.0.15",
"iflow-lodash": "^1.1.15",
"iflow-react-router": "^1.1.15",
"iflow-lodash": "^1.1.17",
"iflow-react-router": "^1.1.17",
"nyc": "^6.6.1"
},
"engines": {
Expand Down