Skip to content
Luis Eduardo Brito edited this page Sep 19, 2013 · 3 revisions

The scripts/ folder stores the classes that ignites some part of the infrastructure of the cluster and have to be run inside the app.js file.

You can call directly a script to start some pre-defined routine, and we encourage you to store your scripts there using the following skeleton:

var MyStartupClass = function(){
    
    var exports = {};
    
    var do = function(){
        console.log("doing stuff..");
    };

    exports.do = do;

    var init = function(){
        return exports;
    }

    return init();
}

module.exports = new MyStartupClass();

And then use in your app.js file as:

var myStartupClass = require("./scripts/mystartupclass.js");

myStartupClass.do(); // will print "doing stuff" in the console

Default Scripts

Server

The class that encapsulates the Express HTTP Server and the Socket.io Server initialization. Cannot be called directly, for that you should use the Single Server script, described below:

Single Server

Script for encapsulating the Server Script and start only one node of the Server. Can be called directly using node scripts/single-server or npm run-script single-server.

Deploy

Script for starting the cluster using Forever module for app uptime improvement, starting it as a Daemon. Can be called directly using node scripts/deploy or npm run-script deploy.

StopAll

Script for stopping all the cluster and its forks externalized by Forever module. Can be called directly using node scripts/stopall or npm run-script stop.

Socket

Script for encapsulating the Socket.io Server class. Not yet fully implemented.

Clone this wiki locally