#!/usr/bin/env node

var path = require('path');
process.env.HARAKA = process.env.HARAKA || path.resolve('.');
require.paths.unshift(path.join(process.env.HARAKA, 'node_modules'));

var fs     = require('fs');
var logger = require('./logger');
var server = require('./server');

exports.version = JSON.parse(
        fs.readFileSync(path.join(__dirname, './package.json'), 'utf8')
    ).version;

process.on('uncaughtException', function (err) {
    if (err.stack) {
        err.stack.split("\n").forEach(logger.logcrit);
    }
    else {
        logger.logcrit('Caught exception: ' + err);
    }
    if (!server.ready) {
        logger.logcrit('Server not ready yet. Stopping.');
        process.exit();
    }
});

logger.log("Starting up Haraka version " + exports.version);


server.createServer();

@@ -23,16 +23,18 @@
 ar path 
+  
 = requir
@@ -44,16 +44,113 @@
 path');%0A
+var fs     = require('fs');%0Avar logger = require('./logger');%0Avar server = require('./server');%0A%0A
 process.
@@ -203,16 +203,24 @@
 e('.');%0A
+try %7B%0A  
 require.
@@ -285,104 +285,150 @@
 ));%0A
-%0Avar fs     = require('fs');%0Avar logger = require('./logger');%0Avar server = require('./server');
+%7D catch(e) %7B%0A  logger.loginfo('No require paths. Must be node v0.5');%0A  process.env.NODE_PATH += ':' + process.env.HARAKA + '/node_modules';%0A%7D
 %0A%0Aex

prepare for v0.5