Skip to content

Commit

Permalink
Merge pull request #58 from JarvusInnovations/develop
Browse files Browse the repository at this point in the history
Release: emergence v1.0.3
  • Loading branch information
themightychris authored Jan 1, 2018
2 parents 9c67040 + 1bae104 commit 99e6b58
Show file tree
Hide file tree
Showing 45 changed files with 967 additions and 971 deletions.
25 changes: 25 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"env": {
"node": true
},
"parserOptions": {
"ecmaVersion": 8
},
"rules": {
"no-const-assign": "warn",
"no-this-before-super": "warn",
"no-undef": "warn",
"no-unreachable": "warn",
"no-unused-vars": "warn",
"constructor-super": "warn",
"valid-typeof": "warn",
"semi": "warn",
"keyword-spacing": "warn",
"space-before-function-paren": "warn",
"space-before-blocks": "warn",
"indent": ["warn", 4],
"no-trailing-spaces": "warn",
"comma-style": ["error", "last"],
"eol-last": ["error", "always"]
}
}
58 changes: 25 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,36 @@
Emergence
=========
# Emergence

[![Join the chat at https://gitter.im/JarvusInnovations/Emergence](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/JarvusInnovations/Emergence?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

Emergence is a NodeJS-powered server that provides a web interface for configuring and launching the services that power your website or application. It provides virtualized storage containers for your code and assets that are accessible via WebDAV and API. Each storage container maintains complete version history for all files and can be linked over the web to a parent container that files will be inherited from just-in-time.

## Features

Features
---------
* Rich web interface provides for all setup and management
* Plugin-based support for system services to be configured and run
* Plugins included for nginx and mysql
* Versioned storage containers
* Inherit remote containers over http
* Copy-on-write
* Accessible remotely via WebDAV and locally via API
* PHP development framework
* Classes automatically loaded from storage container
* Lightweight MVC classes optimized for serial inheritance across sites
* Extendable templating system powered by Dwoo
- Rich web interface provides for all setup and management
- Plugin-based support for system services to be configured and run
- Plugins included for nginx and mysql
- Versioned storage containers
- Inherit remote containers over http
- Copy-on-write
- Accessible remotely via WebDAV and locally via API
- PHP development framework
- Classes automatically loaded from storage container
- Lightweight MVC classes optimized for serial inheritance across sites
- Extendable templating system powered by Dwoo

## Requirements

Requirements
-------------
* NodeJS
* npm
* underscore
* node-static
* mysql
* nginx
* php-fpm
* php 5.3+
* apc
* mysqli
- NodeJS
- npm
- mysql
- nginx
- php-fpm
- php 5.6+
- apcu
- mysqli

## Installation

Installation
--------------
See http://emr.ge/docs
See [http://emr.ge/docs](http://emr.ge/docs)



Visit http://serverhost:9083 in your browser
Visit [http://serverhost:9083](http://serverhost:9083) in your browser
20 changes: 7 additions & 13 deletions bin/kernel
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
#!/usr/bin/env node
var fs = require('fs'),
sitesLib = require('../kernel-lib/sites.js'),

// requirements
var _ = require('underscore'),
util = require('util'),
url = require('url'),
path = require('path'),
fs = require('fs'),
sitesLib = require('../kernel-lib/sites.js');
CONFIG;


var CONFIG;

if (fs.existsSync('/emergence/config.json')) {
// try to load existing kernel config

CONFIG = JSON.parse(fs.readFileSync('/emergence/config.json', 'ascii'));
} else {
// try to smart-init a new kernel config
Expand Down Expand Up @@ -53,8 +46,6 @@ if (fs.existsSync('/emergence/config.json')) {
};




// detect nginx
if (fs.existsSync('/usr/sbin/nginx')) {
CONFIG.services.plugins.web = {
Expand Down Expand Up @@ -138,11 +129,13 @@ if (fs.existsSync('/emergence/config.json')) {
};
}


fs.writeFileSync('/emergence/config.json', JSON.stringify(CONFIG, null, 4));
fs.chmodSync('/emergence/config.json', '600');
console.log('Generated and wrote initial config: /emergence/config.json');
}


// create default admin user
if (!fs.existsSync('/emergence/admins.htpasswd')) {
console.log('Creating default administrative user: admin/admin');
Expand All @@ -155,6 +148,7 @@ if (!fs.existsSync('/emergence/admins.htpasswd')) {
var eSites = sitesLib.createSites(CONFIG);
var eServices = require('../kernel-lib/services.js').createServices(eSites, CONFIG);


// instantiate management server
var eManagementServer = require('../kernel-lib/server.js').createServer({
sites: eSites,
Expand All @@ -163,4 +157,4 @@ var eManagementServer = require('../kernel-lib/server.js').createServer({


// start server
eManagementServer.start();
eManagementServer.start();
34 changes: 17 additions & 17 deletions kernel-lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@ var http = require('http'),
util = require('util'),
fs = require('fs'),
path = require('path'),
_ = require('underscore'),
util = require('util'),
url = require('url'),
static = require('node-static'),
events = require('events'),
nodeCleanup = require('node-cleanup');

exports.Server = function(paths, config) {

exports.createServer = function (paths, options) {
return new Server(paths, options);
};


function Server (paths, config) {
var me = this,
options = config.server;

Expand All @@ -31,10 +36,10 @@ exports.Server = function(paths, config) {
nodeCleanup(this.close.bind(this));
};

util.inherits(exports.Server, events.EventEmitter);
util.inherits(Server, events.EventEmitter);


exports.Server.prototype.start = function() {
Server.prototype.start = function () {
// create authenticator
this.httpAuth = require('http-auth')({
authRealm: 'Emergence Node Management',
Expand Down Expand Up @@ -67,30 +72,25 @@ exports.Server.prototype.start = function() {
console.log('Management server listening on '+this.webProtocol+'://'+this.options.host+':'+this.options.port);
};

exports.createServer = function(paths, options) {
return new exports.Server(paths, options);
};


exports.Server.prototype.handleWebRequest = function(request, response) {
Server.prototype.handleWebRequest = function (request, response) {
var me = this;

me.httpAuth.apply(request, response, function(username) {
me.httpAuth.apply(request, response, function () {
me.handleRequest(request, response);
});
};

exports.Server.prototype.handleRequest = function(request, response) {
Server.prototype.handleRequest = function (request, response) {
var me = this;

request.content = '';

request.addListener('data', function(chunk) {
request.addListener('data', function (chunk) {
request.content += chunk;
});

request.addListener('end', function() {
request.urlInfo = url.parse(request.url)
request.addListener('end', function () {
request.urlInfo = url.parse(request.url);
request.path = request.urlInfo.pathname.substr(1).split('/');
console.log(request.method+' '+request.url);

Expand Down Expand Up @@ -122,7 +122,7 @@ exports.Server.prototype.handleRequest = function(request, response) {
});
};

exports.Server.prototype.close = function(options, error) {
Server.prototype.close = function () {
console.log('Shutting down management server...');

if (this.webServer) {
Expand All @@ -132,4 +132,4 @@ exports.Server.prototype.close = function(options, error) {
if (this.socketServer) {
this.socketServer.close();
}
};
};
27 changes: 14 additions & 13 deletions kernel-lib/services.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
var _ = require('underscore'),
util = require('util'),
fs = require('fs'),
path = require('path'),
events = require('events');

exports.ServicesController = function(sites, config) {

exports.createServices = function (sites, config) {
return new ServicesController(sites, config);
};


function ServicesController (sites, config) {
var me = this,
options = config.services;
options = config.services;

me.sites = sites;

Expand Down Expand Up @@ -47,7 +52,7 @@ exports.ServicesController = function(sites, config) {

// load service plugins
me.services = {};
_.each(me.options.plugins, function(plugin, name) {
_.each(me.options.plugins, function (plugin, name) {
console.log('Loading service: '+name);

if (_.isString(plugin)) {
Expand All @@ -60,18 +65,18 @@ exports.ServicesController = function(sites, config) {
});

// auto-start service plugins
_.each(me.services, function(service, name) {
_.each(me.services, function (service, name) {
if (service.options.autoStart) {
console.log('Autostarting service: '+name);
service.start();
}
});
};

util.inherits(exports.ServicesController, events.EventEmitter);
util.inherits(ServicesController, events.EventEmitter);


exports.ServicesController.prototype.handleRequest = function(request, response, server) {
ServicesController.prototype.handleRequest = function (request) {
var me = this;

if (request.path[1]) {
Expand All @@ -83,7 +88,7 @@ exports.ServicesController.prototype.handleRequest = function(request, response,
services: []
};

_.each(me.services, function(service, name) {
_.each(me.services, function (service) {
statusData.services.push(service.getStatus());
});

Expand All @@ -93,7 +98,7 @@ exports.ServicesController.prototype.handleRequest = function(request, response,
return false;
};

exports.ServicesController.prototype.handleServiceRequest = function(request, response, server) {
ServicesController.prototype.handleServiceRequest = function (request) {
var me = this,
service = me.services[request.path[1]];

Expand Down Expand Up @@ -124,7 +129,3 @@ exports.ServicesController.prototype.handleServiceRequest = function(request, re

return false;
};

exports.createServices = function(sites, config) {
return new exports.ServicesController(sites, config);
};
29 changes: 15 additions & 14 deletions kernel-lib/services/abstract.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
var _ = require('underscore')
,util = require('util')
,events = require('events');
var util = require('util'),
events = require('events');


exports.AbstractService = function(name, controller, options) {
function AbstractService (name, controller, options) {
var me = this;

// call events constructor
exports.AbstractService.super_.apply(me, arguments);
AbstractService.super_.apply(me, arguments);

// initialize options and apply defaults
me.name = name;
Expand All @@ -19,28 +18,30 @@ exports.AbstractService = function(name, controller, options) {
me.status = 'offline';
};

util.inherits(exports.AbstractService, events.EventEmitter);
util.inherits(AbstractService, events.EventEmitter);

module.exports = AbstractService;

exports.AbstractService.prototype.getStatus = function() {

AbstractService.prototype.getStatus = function () {
return {
name: this.name
,status: this.status
name: this.name,
status: this.status
};
}
};

exports.AbstractService.prototype.start = function() {
AbstractService.prototype.start = function () {
throw new Error('start() not implemented in '+this.name);
};

exports.AbstractService.prototype.stop = function() {
AbstractService.prototype.stop = function () {
throw new Error('start() not implemented in '+this.name);
};

exports.AbstractService.prototype.restart = function() {
AbstractService.prototype.restart = function () {
if (this.stop()) {
return this.start();
} else {
return false;
}
};
};
Loading

0 comments on commit 99e6b58

Please sign in to comment.