term-notify-server/index.js

70 lines
1.3 KiB
JavaScript
Raw Normal View History

2016-02-19 19:30:22 +00:00
#!/usr/bin/env node
2016-02-11 16:16:42 +00:00
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;
2016-04-28 08:39:13 +00:00
global.X_SERVER_CLUSTER = cluster;
2016-02-11 16:16:42 +00:00
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();
2016-02-12 13:24:42 +00:00
}, 15602 );
2016-02-11 16:16:42 +00:00
//*/
}