Improve dev vs production distinctions
This commit is contained in:
39
react-ui/src/App.js
vendored
39
react-ui/src/App.js
vendored
@@ -8,17 +8,34 @@ class App extends Component {
|
||||
<div className="App">
|
||||
<header className="App-header">
|
||||
<img src={logo} className="App-logo" alt="logo" />
|
||||
<p>
|
||||
Edit <code>src/App.js</code> and save to reload.
|
||||
</p>
|
||||
<a
|
||||
className="App-link"
|
||||
href="https://reactjs.org"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
Learn React
|
||||
</a>
|
||||
{ process.env.NODE_ENV === 'production' ?
|
||||
|
||||
<p>
|
||||
This is a production build from create-react-app
|
||||
<br/>
|
||||
<br/>
|
||||
<a
|
||||
className="App-link"
|
||||
href="https://github.com/mars/heroku-cra-node"
|
||||
>
|
||||
React + Node deployment on Heroku
|
||||
</a>
|
||||
</p>
|
||||
|
||||
: <p>
|
||||
Edit <code>src/App.js</code> and save to reload.
|
||||
<br/>
|
||||
<br/>
|
||||
<a
|
||||
className="App-link"
|
||||
href="https://reactjs.org"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
Learn React
|
||||
</a>
|
||||
</p>
|
||||
}
|
||||
</header>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -3,10 +3,11 @@ const path = require('path');
|
||||
const cluster = require('cluster');
|
||||
const numCPUs = require('os').cpus().length;
|
||||
|
||||
const isDev = process.env.NODE_ENV !== 'production';
|
||||
const PORT = process.env.PORT || 5000;
|
||||
|
||||
// Multi-process to utilize all CPU cores.
|
||||
if (cluster.isMaster) {
|
||||
if (!isDev && cluster.isMaster) {
|
||||
console.error(`Node cluster master ${process.pid} is running`);
|
||||
|
||||
// Fork workers.
|
||||
@@ -36,6 +37,6 @@ if (cluster.isMaster) {
|
||||
});
|
||||
|
||||
app.listen(PORT, function () {
|
||||
console.error(`Node cluster worker ${process.pid}: listening on port ${PORT}`);
|
||||
console.error(`Node ${isDev ? 'dev server' : 'cluster worker '+process.pid}: listening on port ${PORT}`);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user