Skip to content

Instantly share code, notes, and snippets.

@alejandro
Created August 4, 2012 21:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alejandro/3259935 to your computer and use it in GitHub Desktop.
Save alejandro/3259935 to your computer and use it in GitHub Desktop.
Running geddy on nodester
{
"name": "geddytest",
"version": "0.0.0",
"description": "ERROR: No README.md file found!",
"main": "server.js",
"dependencies": {
"geddy": "~0.4.4"
},
"node":"0.6.17",
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},
"repository": "",
"author": "Alejandro Morales",
"license": "BSD"
}
/* Run an app on nodester */
// Put this script on the root of your app
// and add a package.json with the geddy dependency
// $ nodester npm install <appname> geddy
var fs = require('fs')
var geddy = require('geddy')
var utils = require('geddy/lib/utils/index')
var parseopts = require('geddy/lib/parseopts')
var optsMap = [
{ full: 'origins', abbr: 'o' }
, { full: 'port', abbr: 'p' }
, { full: 'workers', abbr: ['n', 'w'] }
, { full: 'version', abbr: ['v', 'V'], args: false }
, { full: 'help', abbr: 'h', args: false }
, { full: 'debug', abbr: 'd' }
, { full: 'loglevel', abbr: 'l' }
, { full: 'environment', abbr: 'e' }
, { full: 'spawned', abbr: ['s', 'q', 'Q'] }
, { full: 'jade', abbr: 'j', args: false }
, { full: 'handle', abbr: 'H', args: false }
, { full: 'handlebars', abbr: 'H', args: false }
, { full: 'mustache', abbr: 'm', args: false }
];
var parser = new parseopts.Parser(optsMap);
var ar = process.argv.concat(['-p', process.env.app_port || 3300, '-e', process.env.NODE_ENV])
parser.parse(ar.slice(2));
var cmds = parser.cmds;
var opts = parser.opts;
function start () {
geddy.config(opts)
geddy.start()
}
// Override original values (not available on nodester)
var noop = function () { };
fs.existsSync = fs.existsSync || require('path').existsSync
['mkdirSync','unlinkSync','rmdirSync','writeFileSync','writeFile','renameSync'].forEach(function(el) {
return fs[el] = function () {
var args = [].slice.call(arguments)
var cb = args[args.length - 1]
if (cb && typeof cb == 'function') return cb(null, noop)
return noop
}
});
Object.keys(geddy.log || ['log','warn','error']).forEach(function(level) {
if (console[level]){
geddy.log[level] = console[level].bind(console)
} else {
geddy[level] = function () {}
}
})
fs.createWriteStream = console.log.bind(console)
process.chdir(__dirname)
start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment