forked from Automattic/wp-calypso
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
42 lines (36 loc) · 1.12 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
* External dependencies.
*/
var boot = require( 'boot' ),
http = require( 'http' ),
chalk = require( 'chalk' );
/**
* Internal dependencies
*/
var pkg = require( './package.json' ),
config = require( 'config' );
var start = Date.now(),
port = process.env.PORT || 3000,
host = process.env.HOST || config( 'hostname' ),
app = boot(),
server,
hotReloader;
console.log( chalk.yellow( '%s booted in %dms - http://%s:%s' ), pkg.name, ( Date.now() ) - start, host, port );
console.info( chalk.cyan( '\nGetting bundles ready, hold on...' ) );
server = http.createServer( app );
// The desktop app runs Calypso in a fork.
if ( process.env.CALYPSO_IS_FORK ) {
// We need to run it with an explicit hostname to avoid firewall warnings.
server.listen( { port, host }, function() {
// Tell the parent process that Calypso has booted.
process.send( { boot: 'ready' } );
} );
} else {
// Let non-forks listen on any host.
server.listen( port );
}
// Enable hot reloader in development
if ( config( 'env' ) === 'development' ) {
hotReloader = require( 'bundler/hot-reloader' );
hotReloader.listen( server, app.get( 'compiler' ) );
}