Example #1
0
module.exports.load = function(dir, cb) {
  var componentDir, components
  componentDir = dir+'/node_modules'
  components = findComponents(componentDir)

  architect.createApp(components, cb)
}
Example #2
0
 architect.resolveConfig(plugins, __dirname + "/../plugins", function(err, config) {
     if (err) return callback(err);
     
     var app = architect.createApp(config, function (err, app) {
         if (err) {
             return callback(err);
         }
         if (options.getMounts)
             app.services.makestatic.getMounts(options.dest, callback);
         else if (options.symlink)
             app.services.makestatic.symlink(options.dest, callback);
         else if (options["react-style"])
             app.services["react.style"].compile(function(err, code) {
                 if (err) return callback(err);
                 console.log(code);
                 callback();
             });
         else
             app.services.makestatic.copy(options.dest, callback);
     });
     
     app.on("service", function(name, plugin) {
         if (typeof plugin !== "function")
             plugin.name = name; 
     });
 });
before(function(){
    arch.createApp(context, function(err, app){
        if(err) throw err;
        healthcheck = app.services.healthcheck;
        config = app.services.config;
    })
});
Example #4
0
    architect.resolveConfig(plugins, __dirname + "/plugins", function(err, config) {
        if (err) {
            console.error(err);
            process.exit(1);
        }
        
        if (argv.dump) {
            console.log(JSON.stringify(config, null, 2));
            return callback && callback(null, config);
        }
        
        if (argv._getConfig)
            return callback && callback(null, config);

        var app = architect.createApp(config, function (err, app) {
            if (err) {
                console.trace("Error while starting '%s':", configPath);
                console.log(err, err.stack);
                process.exit(1);
            }
            console.log("Started '%s' with config '%s'!", configPath, settingsName);
            
            callback && callback(null, app);
        });
        
        app.on("service", function(name, plugin) {
            if (typeof plugin !== "function")
                plugin.name = name; 
        });
    });
Example #5
0
  bootstrapMemcached : function bootstrapMemcached(callback) {
    var memcached = path.join(__dirname, 'architecture', 'memcached.js');
    var config = architect.loadConfig(memcached);
    architect.createApp(config, function (error, app) {
      if (error) return helper.cleanMemcached(app, function () { return callback(error); });

      return callback(null, app);
    });
  },
Example #6
0
  bootstrapMongoDB : function bootstrapMongoDB(callback) {
    var bootstrapped = path.join(__dirname, 'architecture', 'mongodb-bootstrapped.js');
    var config = architect.loadConfig(bootstrapped);
    architect.createApp(config, function (error, app) {
      if (error) return helper.cleanMongoDB(app, function () { return callback(error); });

      return callback(null, app);
    });
  },
  bootstrapMySQL : function bootstrapMySQL(callback) {
    var bootstrapped = path.join(__dirname, 'architecture', 'mysql-bootstrapped.js');
    var config = architect.loadConfig(bootstrapped);
    architect.createApp(config, function (error, app) {
      if (error) return callback(error);

      return callback(null, app);
    });
  },
  bootstrapRedis : function bootstrapRedis(callback) {
    var redis = path.join(__dirname, 'architecture', 'redis.js');
    var config = architect.loadConfig(redis);
    architect.createApp(config, function (error, app) {
      if (error) return helper.cleanRedis(app, function () {
        return callback(error);
      });

      return callback(null, app);
    });
  },
Example #9
0
return function(options, imports, register) {
    
    var pluginObject = imports;
    var registerObject = {};
    registerObject[pluginName] = pluginObject;
    
    var Architect = require("architect");
    
    if(!options.plugins){
        options.plugins = [];
        var dirList = fs.readdirSync(pluginDir);
        for(var i = 0; dirList.length >= i;i++){
            if(dirList[i]){
                if(options.pluginOptions && options.pluginOptions[dirList[i]]){
                    options.pluginOptions[dirList[i]].packagePath = pluginDir+"/"+dirList[i];
                    options.plugins.push(options.pluginOptions[dirList[i]]);
                }else{
                    options.plugins.push(pluginDir+"/"+dirList[i]);
                }
            }
        }
        //console.log(options.plugins);
    }
    
    var ArchitectConfig = Architect.resolveConfig(options.plugins, pluginDir);
    
    ArchitectConfig.push({
        packagePath:__dirname,
        consumes:["hub"],
        provides:[pluginName],
        setup:function($options, $imports, $register){
            $imports.hub.on("service", function(name, plugin) {
                if(!plugin.name)plugin.name = name;
                
                registerObject[pluginName][plugin.name] = plugin;
                //console.log("Service loaded " + name);
            });
            $imports.hub.on("ready", function(app) {
                var plugins = app.services;
                init(registerObject[pluginName], plugins);
                register(null, registerObject);
                console.log(pluginName,"Loaded!");
            });
            $register(null, registerObject);
        }
    });

    Architect.createApp(ArchitectConfig, function(err, architect) {
        if (err) {
            console.log(err);
            register(err);
        }
    });
};
Example #10
0
exports.main = function(configName, callback) {
    var configPath = path.join(__dirname, "configs", configName);
    var config = architect.loadConfig(configPath);

    architect.createApp(config, function (err, app) {
        if (err) {
            console.error("While starting the '%s':", configPath);
            return callback(err);
        }
        console.log("Started '%s'!", configPath);
        callback(null, app);
    });
};
Example #11
0
  bootstrapMySQL : function bootstrapMySQL(callback) {
    var bootstrapped = path.join(__dirname, 'architecture', 'mysql-bootstrapped.js');
    var config = architect.loadConfig(bootstrapped);
    architect.createApp(config, function (error, app) {
      var cleanup = helper.cleanMySQL.bind(helper, app,
                                           function() { console.error("cleaned up!"); });
      process.on('uncaughtException', cleanup);
      process.on('SIGINT', cleanup);

      if (error) return helper.cleanMySQL(app, function () { return callback(error); });

      return callback(null, app);
    });
  },
Example #12
0
// hostname == request.headers.host
// ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress
function boot(dirname, workdir, options, cb) {
  var debug = options.debug || false;
  var packed = options.packed || false;
  var packedName = options.packedName || '';
  var ip = options.ip || '0.0.0.0';
  var port = options.port || 0;

  if (!(cb instanceof Function)) {
    throw new BootIdeException('callback must be function, got: ' + cb);
  }

  var plugins = ideconfig.getConfig(
      dirname,
      workdir,
      ip,
      port);

  //archive(plugins, 'plugins.txt');

  // server plugins
  plugins.forEach(function(plugin) {
    if (plugin.packagePath && /\.\/cloud9.core$/.test(plugin.packagePath)) {
      //TODO: strange, in the original configuration
      // does that mean this is always overridden?
      if (!plugin.debug) {
        plugin.debug = debug;
      }

      plugin.packed = packed;
      plugin.packedName = packedName;
    }
  });

  architect.createApp(
      architect.resolveConfig(
      plugins,
      path.join(dirname, 'plugins-server')),
      function(err, app) {
        if (err) {
          console.error("While starting the '%s' for '%s':", dirname, workdir);
          cb(err);
        } else {
          console.log("Started '%s' for '%s'!", dirname, workdir);
          var address = app.services.http.getServer().address();
          cb(null, address);
        }
      }
  );
}
Example #13
0
module.exports = function bootstrap(next) {
  logger.debug("Awakening the architect.");

  var config = architect.loadConfig(services);
  architect.createApp(config, function (error, app) {
    if (error) {
      logger.debug('The architect was unable to awaken! Abandoning hope.');

      app.destroy();
      return next(error);
    }
    else {
      logger.debug("The architect is in control.");
      return next();
    }
  });
};
Example #14
0
function boot() {
	var configPath = path.resolve(__dirname, "./configs/", configName);
	var plugins = require(configPath);

	// server plugins
	plugins.forEach(function(plugin) {
	   if (plugin.packagePath && /\.\/cloud9.core$/.test(plugin.packagePath)) {
	       plugin.debug = debug;
	       plugin.packed = packed;
	       plugin.packedName = packedName;
	   }
	});

  architect.createApp(architect.resolveConfig(plugins, __dirname + "/plugins-server"), function (err, app) {
	   if (err) {
	       console.error("While starting the '%s':", configPath);
	       throw err;
	   }
	   console.log("Started '%s'!", configPath);
	});
}
Example #15
0
architect.createApp(architect.loadConfig(configPath), function (error, app) {
  if (error) return console.error(error);

  var dal = app.getService('sequelizeDAL')
    , sequelize = dal.sequelize
    , Sequelize = dal.Sequelize
    ;

  var TestEAV = sequelize.define('test_eav', {
    // everyone's favorite relational antipattern
    entity    : {type : Sequelize.STRING, allowNull : false},
    attribute : {type : Sequelize.STRING, allowNull : false},
    value     : {type : Sequelize.TEXT,   allowNull : false}
  });

  var sundowner = function (exitCode) {
    var mysqld = app.getService('mysqldProcess');
    mysqld.shutdown(function cb_shutdown() {
      process.exit(exitCode);
    });
  };

  process.on('SIGINT', function () {
    sundowner(0);
  });

  TestEAV.sync().success(function cb_success() {
    bootstrapExpress(TestEAV);
  }).error(function cb_error(error) {
    console.error(error);
    console.error("Welp, that didn\'t work. Bailing out!");
    sundowner(-1);
  });
});
var architect = require('architect');
var debug = true;

var configPath = path.join(__dirname, "ModulesConfig.js");
var cluster = require('cluster');

var cpuCount = require('os').cpus().length;
if (cluster.isMaster && !debug) {
    for (var i = 0; i <= cpuCount - 1; i++) {
        var worker = cluster.fork();
        console.log('Worker with pid: %s started', worker.process.pid);
        worker.on('message', function(msg) {
            console.log(msg);
        });
    };

    cluster.on('exit', function(worker, code, signal) {
        console.log('worker ' + worker.process.pid + ' died. Respawning...');
        cluster.fork();
    });
} else {
    var config = architect.loadConfig(configPath);
    architect.createApp(config, function createArchitectAppDlg(err, app) {
        if (err) {
            console.log(err);
        } else {
            app.services.HttpServer.start();
            console.log('Server started successfully');
        }
    });
}
Example #17
0
#!/usr/bin/env node

const path = require('path');
const architect = require('architect');
const configPath = path.join(__dirname, 'config.js');
const config = architect.loadConfig(configPath);

architect.createApp(config, err => {
  if (err) throw err;
  console.log('Vivi woke up');
});
Example #18
0
    configName = "default";
}
var debug = false;
if (process.argv.indexOf("-d") >= 0 ) {
    debug = true;
}
var real = false;
if (process.argv.indexOf("-r") >= 0 ) {
    real = true;
}

var configPath = path.resolve(__dirname, "./configs/", configName);
var config = require(configPath);

config.containers.master.plugins.forEach(function(plugin) {
    if (plugin.packagePath && /\/cloud9.core$/.test(plugin.packagePath)) {
        plugin.debug = debug;
        plugin.real = real;
    }
});

architect.createApp(config, {
    console: ((debug)?console:null)
}, function (err, app) {
    if (err) {
        console.error("While starting the '%s':", configPath);
        throw err;
    }
    console.log("Started '%s'!", configPath);
});
Example #19
0
var path = require('path');
var architect = require('architect');

var configPath = path.join(__dirname, 'architecture.js');
var config = architect.loadConfig(configPath);

architect.createApp(config, function (err, app) {
    if (err) throw err;
});
Example #20
0
#!/usr/bin/env node

var path = require('path');
var architect = require("architect");

var configPath = path.join(__dirname, "config.js");
var config = architect.loadConfig(configPath);

architect.createApp(config, function (err, app) {
    if (err)
        throw err;
    console.log("app ready");
});
Example #21
0
var upload_target_path = '';


//////////////////////////////////
//	Coconut Manager plugin 
var path = require('path');
var architect = require("architect");
var plugin_configPath = path.join(__dirname, "./plugins.js");
if(fs.existsSync( plugin_configPath))
{
	var plugin_config = architect.loadConfig(plugin_configPath);

	architect.createApp(plugin_config, function (err, app) {
	  if (err){
	  	console.log("plugin Error >>" + err);	
	  }else{
	  	console.log("Loading complete plugins !");	
	  }
	  
	});
}else{
	console.log("Failed to load plugins. Check the file 'plugins.js' !");	
}
//	Coconut Manager Manager 
//////////////////////////////////
/////////////////////////////////////////////////
//	WAS for Monitor
appSrv.use(bodyParser.json());
appSrv.use(bodyParser.urlencoded());

app.use(bodyParser.json());
app.use(bodyParser.urlencoded());
Example #22
0
exports.main = function main(host, port, callback) {

    var plugins = [
        {
            packagePath: "connect-architect/connect",
            host: host,
            port: port
        },
        {
            packagePath: "connect-architect/connect.static",
            prefix: "/static"
        },
        {
            packagePath: "connect-architect/connect.session",
            key: "connect.architect." + port,
            secret: "1234"
        },
        {
            packagePath: "connect-architect/connect.session.memory"
        },
        {
            packagePath: "architect/plugins/architect.log"
        },
        {
            packagePath: "./../server-plugin",
            messageRoute: /^\/transport\/ser[ver]+/,
            messagePath: "/transport/server",
            debug: true
        },
        {
            provides: [],
            consumes: [
                "smith.transport.server",
                "connect"
            ],
            setup: function(options, imports, register) {

                imports.connect.useStart(imports.connect.getModule().static(PATH.join(__dirname, "www")));

                var TRANSPORT = imports["smith.transport.server"];

                // Fires once for every *new* client connection (not reconnects).
                TRANSPORT.on("connect", function(connection) {

                    console.log("Connected:", connection.id);

                    // Fires once after reconnect attempts have failed and a timeout has passed.
                    connection.once("disconnect", function(reason) {
                        console.log("Disconnected:", connection.id, reason);
                    });

                    connection.on("message", function(message) {
                        console.log("Got message:", message);
                        if (typeof message === "string" && message.indexOf("ping:") === 0) {
                            connection.send("pong: " + message.match(/\d+$/)[0]);
                        }
                    });

                    connection.send({say:"Connected"});

                    connection.on("away", function() {
                        console.log("Away:", connection.id);
                        connection.send({say:"While server away"});
                    });

                    connection.on("back", function() {
                        console.log("Back:", connection.id);
                        connection.send({say:"Server back"});
                    });
                });

                register(null, {});
            }
        }
    ];

    ARCHITECT.createApp(ARCHITECT.resolveConfig(plugins, __dirname), function (err, app) {
        if (err) {
            return callback(err);
        }
        callback(null, app);
    });
}
var configPath = path.join(__dirname, 'architecture/mongoose-bootstrapped.js');
architect.createApp(architect.loadConfig(configPath), function (error, app) {
  if (error) return console.error(error);

  var dal    = app.getService('mongooseDAL')
    , db     = dal.db
    , Schema = dal.mongoose.Schema
    ;

  var schema = new Schema({
    entity    : String,
    attribute : String,
    value     : String
  });

  var TestEAV = db.model('test_eav', schema);

  var sundowner = function (exitCode) {
    var mongod = app.getService('mongodbProcess');
    mongod.shutdown(function cb_shutdown() {
      process.exit(exitCode);
    });
  };

  process.on('SIGINT', function () {
    console.error("erk!");
    sundowner(0);
  });

  bootstrapRestify(TestEAV);
});
// requires dependencies
var path = require('path');
var architect = require('architect');

// requires configs
var configName = process.argv[2] || 'config';
var configPath = path.join(__dirname, configName);
var config = architect.loadConfig(configPath);

// starts app
architect.createApp(config).on('ready', function(app){
  console.log('Started with "%s" config file.', configName);
});
Example #25
0
var PluginManager = function () {
  var _config_path = "./pluginconfig.js";
  var _config      = architect.loadConfig(_config_path);
  this.pluginMgr   = architect.createApp(_config, function (err) {});
};
Example #26
0
var path = require('path'),
    architect = require('architect');

var architectConfig = architect.loadConfig(path.resolve('./config/architect.js'));

architect.createApp(architectConfig, function (err, app) {
    if (err) {
        throw err;
    } else {
        var hapiServer = app.services.hapiServer;

        hapiServer.server.start(function () {
            console.log("Server started at " + hapiServer.config.packs.web.port);
        });
    }
});
Example #27
0
import path from 'path';
import architect from 'architect';

var configPath = path.join(__dirname, 'config','index.js');
var config = architect.loadConfig(configPath);

architect.createApp(config, function (err) {
  if(err) {
    throw err;
  }
});
Example #28
0
var architect = require('architect');
var Config = require('./Common/Config');

var configPath = path.join(__dirname, "ApplicationConfig.js");
var cluster = require('cluster');
var cpuCount = require('os').cpus().length;

if (cluster.isMaster && !Config.debug) {
    for (var i = 0; i <= cpuCount - 1; i++) {
        var worker = cluster.fork();
        console.log('Worker with pid: %s started', worker.process.pid);
        worker.on('message', function(msg) {
            console.log(msg);
        });
    };

    cluster.on('exit', function(worker, code, signal) {
        console.log('worker ' + worker.process.pid + ' died. Respawning...');
        cluster.fork();
    });
} else {
    var config = architect.loadConfig(configPath);
    architect.createApp(config, function createArchitectAppDlg(err, app) {
        if (err) {
            console.log(err);
        } else {
            app.services.HttpServer.start();
            console.log('Server started on port ' + Config.HttpServer.port);
        }
    });
}
Example #29
0
var configPath = __dirname+"/config.js";
var plugins = require(configPath);

Architect.createApp(Architect.resolveConfig(plugins, __dirname + "/server-plugins"), function(err, architect) {
    if (err) {
        console.error("While compiling app config '%s':", configPath);
        throw err;
    }else{
        var welder = architect.services.welder;
        for(var i in architect.config){
            var Package = require(architect.config[i].packagePath+"/package.json");
            if(Package.client){
                var exports = {};
                for(var j in architect.config[i].provides){
                    exports[architect.config[i].provides[j]] = architect.services[architect.config[i].provides[j]];
                }
                welder.addWelderPlugin(architect.config[i].packagePath,exports);
            }
        }
        welder.buildClient(__dirname+'/build/client.js',function(err){
            if(err){
                console.error("While Building app '%s'", err);
            }else{
                process.exit();
            }
        });
    }
});

var fs = require('fs');

var path = require('path');
var architect = require('architect');

var configPath = path.join(__dirname, './config.js');
var config = architect.loadConfig(configPath);

architect.createApp(config, function(err, app) {
  if (err) {
    console.log(err);
    process.exit(1);
  }

});