Permalink
Browse files

Merge Devel Branch

  • Loading branch information...
richtera committed Jul 22, 2012
2 parents 5a81e8c + 9786efa commit 8572e38df7501a1289c80647c81951ee2ac8d703
Showing 311 changed files with 22,516 additions and 13,268 deletions.
View
@@ -2,8 +2,6 @@ conf
tmp
lib-cov
node_modules
-modules/downloaded
-modules/custom
modules/community
modules/private
modules/site
@@ -12,8 +10,11 @@ themes/custom
themes/community
themes/private
themes/site
+media/*
+conf/*.json
*.pid
*.log
*.swp
*.sock
*.gz
+*.sass-cache
View
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>calipso</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- </buildSpec>
- <natures>
- </natures>
-</projectDescription>
View
@@ -1,3 +1,5 @@
language: node_js
node_js:
- - 0.4
+ - 0.6
+ - 0.7
+ - 0.8
View
@@ -0,0 +1,30 @@
+
+REPORTER = spec
+MOCHA_FLAGS = -t 5000 -s 500
+
+test:
+ @NODE_ENV=mocha ./node_modules/.bin/mocha \
+ --reporter $(REPORTER) $(MOCHA_FLAGS)
+
+test-debug-brk:
+ @NODE_ENV=mocha ./node_modules/.bin/mocha \
+ --reporter $(REPORTER) $(MOCHA_FLAGS) --debug-brk
+
+test-debug:
+ @NODE_ENV=mocha ./node_modules/.bin/mocha \
+ --reporter $(REPORTER) $(MOCHA_FLAGS) --debug
+
+test-cov:
+ -rm -rf lib-cov
+ jscoverage --no-highlight lib lib-cov
+ -NODE_ENV=mocha CALIPSO_COV=1 ./node_modules/.bin/mocha --reporter html-cov -t 5000 -s 500 > docs/coverage.html
+ rm -rf lib-cov
+
+site:
+ rm -fr /tmp/docs \
+ && cp -fr docs /tmp/docs \
+ && git checkout gh-pages \
+ && cp -fr /tmp/docs/* . \
+ && echo "Pages updated ..."
+
+.PHONY: site test test-cov test-debug test-debug-brk lib-cov
View
@@ -6,11 +6,7 @@ For additional details, including installation instructions, please visit the ho
If you would like to contribute, please take a look at the issues list as this will have the most up to date view of work that needs to be done for the next minor release. Otherwise, please just pm myself (cliftonc), dennis (dennishall) or dale (dtan) and we can suggest some places for you to start.
-h3. Update - April 2012
-
-Hi all, apologies for the lack of work recently, but I've moved jobs, got married and had the delivery of our amazing Son! I'm planning on spending some time getting things back on track, and have moved the devel branch into working mode against v0.6.14+. That branch needs some work completing, most notably the default theme needs to be fixed, the install re-checked and permissions finished.
-
-Please let me know if you're keen to help, coming back to this after a bit of a break has made me realise that a whole lot of the core needs refactoring to make it easier to test and make the core calipso.js more modular and easy to modify - but there is always work to do!
+!https://secure.travis-ci.org/cliftonc/calipso.png?branch=master(Build Status)!:http://travis-ci.org/cliftonc/calipso
h3. Quick Install
@@ -37,16 +33,16 @@ Since node v0.5.3 has removed <code>require.paths</code>, in order to <code>requ
That also goes for including anything that is based on the root path of the project directory.
-h4. Note on Ubuntu
-
-Sometimes to install the mongodb client on Ubuntu, you need to pass through the --mongodb:native parameter (only try this if you have problems with the typical install, it doesn't seem to occur on the most recent versions of the mongodb client):
+h3. Development Steps
-<pre><code>
- npm install calipso -g --mongodb:native
+To get running in development mode (not the site mode outlined on the front page) - e.g. so you can make changes to core and submit pull requests:
-</pre></code>
+1. Fork the repository
+2. Clone from your fork (replace YOURNAME!): git clone git@github.com:YOURNAME/calipso.git
+3. Run 'npm install -d' in the clone folder to install all of the dependencies.
+4. Run 'node app' to run Calipso from the source folder.
-This is relatively new, and as I am working on the module management functions there are some tricky dependencies in core (e.g. expat, mongodb) that require compilation and can cause issues. Please raise / update issues if you find them.
+Note that the bin/calipso command line script is really designed to allow people who just want to use Calipso to build sites to use it, it isn't used in the dev process. As always, any questions please do shout.
h3. Calipso Command Line Client
@@ -93,3 +89,5 @@ h3. Contributors
* "Martin Moen":https://github.com/botto
* "dale tan":https://github.com/dtan
* "Nate Hunzaker":https://github.com/nhunzaker
+ * "Andreas Richter":https://github.com/richtera
+
View
@@ -1,40 +1,132 @@
/**
- * Calipso script for running in clustered mode. Usage: node app-cluster, or
- * NODE_ENV=production node app-cluster
+ * Master server process
+ * Initialises a number of instances of the app, based on the number of CPU's it detects
+ * is available.
+ *
+ * First arg is the port
+ * Second arg is the num worker threads;
+ *
+ * e.g. node server 3000 8
+ *
*/
-var cluster = require('cluster');
-var port = 3000;
-var path = __dirname;
-var app;
+// Dependencies
+var rootpath = process.cwd() + '/',
+ cluster = require('cluster'),
+ path = require('path'),
+ logo = require(path.join(rootpath, 'logo')),
+ colors = require('colors'),
+ port = process.env.PORT || 3000,
+ restarts = 0,
+ totalWorkers = 0,
+ runningWorkers = 0;
+
+var argv = processArgs();
+
+launchServer();
+
+/**
+ * Launch server instance, initially master, then each worker instance is forked.
+ * All instances share same config.
+ */
+function launchServer() {
+
+ // Check if we are the master process
+ if (cluster.isMaster) {
+
+ //require('./app').boot(function (app) {
+
+
+ // Load configuration
+ var Config = require(rootpath + "lib/core/Configuration"),
+ config = new Config();
+
+ config.init();
+
+ // Print the logo
+ logo.print();
+
+ // Set the number of workers
+ totalWorkers = config.get('server:cluster:workers') || argv.c;
+
+ // Fork workers based on num cpus
+ console.log("Loading ".green + totalWorkers + " workers, please wait ...".green);
+ for (var i = 0; i < totalWorkers; i++) {
+ forkWorker();
+ }
+
+ // Log worker death
+ // TODO : Auto restart with number of retries
+ cluster.on('death', function(worker) {
+
+ console.error('worker ' + worker.pid + ' died ...');
+
+ // Manage restarting of workers
+ if(config.get('server:cluster:restartWorkers')) {
+ if(restarts > config.get('server:cluster:maximumRestarts')) {
+ console.error('Maximum number of restarts reached, not restarting this worker.'.red);
+ } else {
+ restarts++;
+ forkWorker();
+ }
+ }
+
+ });
+
+ //});
+
+ } else {
+
+ // We are a child worker, so bootstrap the app.
+ require(rootpath + 'app').boot(true, function (app) {
+
+ //logger.info("Worker [" + argv.m.cyan + "] with pid " + (process.pid + "").grey + " online.");
+ app.listen(port);
+
+ process.send({ cmd: 'workerStarted', pid: process.pid, port: port });
+
+ });
+
+ }
+
+}
+
+/**
+ * Helper function to fork a worker, we need to reset the counter in the master thread
+ * hence the messaging back, also deal with messaging around job management from worker threads.
+ */
+function forkWorker() {
+
+ var worker = cluster.fork();
+
+ worker.on('message', function(msg) {
+
+ if (msg.cmd) {
+
+ if(msg.cmd == 'workerStarted') {
+
+ runningWorkers++;
+
+ if(runningWorkers === parseInt(totalWorkers)) {
+ console.log("Calipso configured for: ".green + (global.process.env.NODE_ENV || 'development') + " environment.".green);
+ console.log("Calipso server running ".green + runningWorkers + " workers, listening on port: ".green + port);
+ }
+
+ }
+
+ }
+
+ });
+
+}
/**
- * Create an instance of calipso via the normal App.
+ * Process command line arguments using optimist
*/
-require('./app').boot(function (app) {
-
- /**
- * TODO: Check to ensure that the logs and pids folders exist before launching
- */
-
- cluster(app)
- .set('working directory', path)
- .set('socket path', path)
- .in('development')
- .set('workers', 4)
- .use(cluster.logger(path + '/logs', 'debug'))
- .use(cluster.debug())
- .use(cluster.pidfiles(path + '/pids'))
- .use(cluster.stats({ connections: true, lightRequests: true }))
- .in('test')
- .set('workers', 4)
- .use(cluster.logger(path + '/logs', 'warning'))
- .use(cluster.pidfiles(path + '/pids'))
- .in('production')
- .set('workers', 4)
- .use(cluster.logger(path + '/logs'))
- .use(cluster.pidfiles(path + '/pids'))
- .in('all')
- .listen(port);
-
-
-});
+function processArgs() {
+ return require('optimist')
+ .usage('Launch Calipso in Clustered Mode\nUsage: $0')
+ .describe('c', 'Number of CPUs')
+ .alias('c', 'cpu')
+ .default('c', require('os').cpus().length)
+ .argv;
+}
Oops, something went wrong.

0 comments on commit 8572e38

Please sign in to comment.