term-notify-server/index.js

70 lines
1.3 KiB
JavaScript
Executable File

#!/usr/bin/env node
require( "./botanss/package" );
require( "./config/global" );
var cl = global.botanLoader;
var Dragonfly = cl.load( "botanss.Dragonfly" );
Dragonfly.defaultSphere = 999;
var cluster = require('cluster');
var numCPUs = 2;
if( cluster.isMaster )
{
var clog = require( "./config/log" );
var Masterfly = new Dragonfly( clog.handler );
var procFock = function( c )
{
// fork and bind the message bus from masterfly
c.fork().addListener( "message", Masterfly.messageBus );
};
var clusterDisconnect = function( worker )
{
if( worker.suicide === true )
{
Masterfly.Info( "Worker committed suicide" );
Masterfly.Info( "Forking process ..." );
procFock( cluster );
}
else
{
Masterfly.Info( "Worker died" );
}
};
for( var i = 0; i < numCPUs; i ++ ) procFock( cluster );
cluster.addListener( "disconnect", clusterDisconnect );
}
else
{
Dragonfly = new Dragonfly();
global.Dragonfly = Dragonfly;
global.X_SERVER_CLUSTER = cluster;
var AppDomain = cl.load( "botanss.net.AppDomain" );
var Httph = cl.load( "botanss.net.Http" );
//* Host App
// Define AppNS
cl.rootNS( "notifyterm", "./notify-term" );
cl.rootNS( "notifysrv", "./notifysrv" );
var App = cl.load( "notifyterm.app" );
new AppDomain( function( req, res )
{
var h = new Httph( req, res );
new App( h ).run();
}, 15602 );
//*/
}