forked from freeCodeCamp/freeCodeCamp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit does the following: Production start should use the following command `npm run start-producion` this first runs bower install and builds the front end app(react). Then it will use the `pm2Start` script. This script will set up the pm2 daemons to run loopback in cluster mode. This script also use `production-start` script instead of the regular `server` script. The reasons are two fold: to ensure `server` is run in es7 mode, and to wait for handshake from DB or kill itself if no DB can be found within a certain amount of time.
- Loading branch information
Berkeley Martinez
authored and
Berkeley Martinez
committed
Jul 25, 2015
1 parent
00b81f4
commit c0eda90
Showing
5 changed files
with
45 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
// use this file with runners like node-debug | ||
// or mocha. | ||
require('babel/register'); | ||
var app = require('./server'); | ||
|
||
app.start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// this ensures node understands the future | ||
require('babel/register'); | ||
|
||
var startTime = Date.now(); | ||
var timeoutHandler; | ||
// this is where server starts booting up | ||
var app = require('./server'); | ||
console.log('waiting for db to connect'); | ||
|
||
|
||
var onConnect = function() { | ||
console.log('db connected in %s ms', Date.now() - startTime); | ||
if (timeoutHandler) { | ||
clearTimeout(timeoutHandler); | ||
} | ||
app.start(); | ||
}; | ||
|
||
var timeoutHandler = setTimeout(function() { | ||
var message = | ||
'db did not after ' + | ||
(Date.now() - startTime) + | ||
' ms connect crashing hard'; | ||
|
||
console.log(message); | ||
// purposely shutdown server | ||
// pm2 should restart this in production | ||
throw new Error(message); | ||
}, 5000); | ||
|
||
app.dataSources.db.on('connected', onConnect); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters