Commit 8f45b317 authored by Aaron Harder's avatar Aaron Harder
Browse files

bl-start: Simple sling process manager

parent 814099fc
......@@ -6,6 +6,7 @@ var _path=require("path");
var c=require("../../libs/colors");
var fs=require("fs");
var _=require("lodash");
var config=require("config");
module.exports=function(options){
var root=options.blacklightRoot;
......@@ -16,6 +17,8 @@ module.exports=function(options){
var componentHBS = new RegExp(componentRoot + ".*\\.hbs")
var ASSET_WATCH_TIMEOUT=600000;
/*********************************************************************************/
/** Main Blacklight service */
var child=new (forever.Monitor)(script,{
minUptime: 2000,
spinSleepTime: 1000,
......@@ -33,7 +36,7 @@ module.exports=function(options){
message("Blacklight is failing. Please correct the issue to restart.\n");
});
// child.start();
child.start();
function message(msg){
console.log(c.green("bl-start: "), c.white(msg));
......@@ -57,6 +60,8 @@ module.exports=function(options){
chokidar.watch(restartPaths, watchOpts).on("all",restart);
/*********************************************************************************/
/** Module asset watcher */
var modules = options.moduleBuilder.listInstalledModules();
function setupModuleAsset(){
......@@ -104,6 +109,37 @@ module.exports=function(options){
}
setupModuleAsset();
/*********************************************************************************/
/** Sling process manager */
var sling=_.get(config,"bl-start.sling");
if(sling){
if(!sling.path){
var msg="'config.bl-start.sling' exists, but no Sling JAR path specified in 'path' property. Please correct. Exiting."; message(msg); throw new Error(msg);}
var env=sling.javaHome?{JAVA_HOME: sling.javaHome}:{};
var memory = sling.memory || "512M";
var port = sling.port || "4500";
var slingRoot =_path.dirname(sling.path);
message("Starting Sling from: " + c.blue(slingRoot));
var slingProcess=new (forever.Monitor)([ 'java', '-Xmx' + memory, '-jar', sling.path, "-p", port],{
minUptime: 20000,
spinSleepTime: 20000,
killTree: true,
silent: false,
env: env,
cwd: slingRoot,
watch:false,
max: 1
});
slingProcess.start();
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment