Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initial commit

  • Loading branch information...
commit c00f957909c0dfdea03a789d0603bc16142bd97b 1 parent e249516
@camshaft authored
View
1  .gitignore
@@ -12,3 +12,4 @@ logs
results
npm-debug.log
+node_modules
View
15 bin/startup
@@ -0,0 +1,15 @@
+#!/usr/bin/env node
+
+/**
+ * Module dependencies.
+ */
+
+var startup = require('commander')
+ , join = require('path').join;
+
+startup
+ .version(require(join(__dirname, "../package.json")).version)
+ .command('start [path]', 'start app at path')
+ .command('middleware [path]', 'list app middleware')
+ .command('settings [path]', 'list app settings')
+ .parse(process.argv);
View
34 bin/startup-middleware
@@ -0,0 +1,34 @@
+#!/usr/bin/env node
+
+/**
+ * Module dependencies.
+ */
+
+var startup = require('commander')
+ , join = require('path').join
+ , http = require('http')
+ , Table = require('cli-table');
+
+startup
+ .version(require(join(__dirname, "../package.json")).version)
+ .option('-p --path', 'path to file', 'app.js')
+ .option('-d --dev', 'run in development mode', false)
+ .parse(process.argv);
+
+var path = startup.path?
+ join(process.cwd(), startup.path):
+ join(process.cwd(), 'app');
+
+var app = require(path)
+ , port = process.env.PORT || 3000;
+
+var table = new Table({
+ head: ["Route", "Name"],
+ colWidths: [20, 60]
+});
+
+app.stack.forEach(function(middleware) {
+ table.push([(middleware.route || '/'), middleware.handle.name]);
+});
+
+console.log(table.toString());
View
34 bin/startup-settings
@@ -0,0 +1,34 @@
+#!/usr/bin/env node
+
+/**
+ * Module dependencies.
+ */
+
+var startup = require('commander')
+ , join = require('path').join
+ , http = require('http')
+ , Table = require('cli-table');
+
+startup
+ .version(require(join(__dirname, "../package.json")).version)
+ .option('-p --path', 'path to file', 'app.js')
+ .option('-d --dev', 'run in development mode', false)
+ .parse(process.argv);
+
+var path = startup.path?
+ join(process.cwd(), startup.path):
+ join(process.cwd(), 'app');
+
+var app = require(path)
+ , port = process.env.PORT || 3000;
+
+var table = new Table({
+ head: ["Key", "Value"],
+ colWidths: [20, 80]
+});
+
+for(var key in app.settings) {
+ table.push([key, app.settings[key]]);
+}
+
+console.log(table.toString());
View
55 bin/startup-start
@@ -0,0 +1,55 @@
+#!/usr/bin/env node
+
+/**
+ * Module dependencies.
+ */
+
+var startup = require('commander')
+ , join = require('path').join
+ , http = require('http')
+ , domain = require('domain');
+
+startup
+ .version(require(join(__dirname, "../package.json")).version)
+ .option('-p --path', 'path to file', 'app.js')
+ .option('-d --dev', 'run in development mode', false)
+ .parse(process.argv);
+
+var path = startup.path?
+ join(process.cwd(), startup.path):
+ join(process.cwd(), 'app');
+
+var app = require(path)
+ , port = process.env.PORT || 3000;
+
+// create a top-level domain for the server
+var serverDomain = domain.create();
+
+serverDomain.run(function() {
+ http.createServer(function(req, res) {
+ var reqd = domain.create();
+ reqd.add(req);
+ reqd.add(res);
+ reqd.on('error', function(err) {
+ console.error('Error', r, req.url);
+ try {
+ res.writeHead(500);
+ res.end('Error occurred, sorry.');
+ res.on('close', function() {
+ // forcibly shut down any other things added to this domain
+ reqd.dispose();
+ });
+ } catch (err) {
+ console.error('Error sending 500', err, req.url);
+ // tried our best. clean up anything remaining.
+ reqd.dispose();
+ }
+ });
+ // Call our app in the req domain
+ reqd.bind(function() {
+ return app(req, res);
+ })();
+ }).listen(port, function(){
+ console.log("Server listening on port " + port);
+ });
+});
View
32 package.json
@@ -0,0 +1,32 @@
+{
+ "name": "startup",
+ "version": "0.0.0",
+ "description": "Node.js HTTP app runner",
+ "scripts": {
+ "test": "./node_modules/.bin/mocha"
+ },
+ "bin": {
+ "startup": "bin/startup"
+ "startup-middleware": "bin/startup-middleware"
+ "startup-settings": "bin/startup-settings"
+ "startup-start": "bin/startup-start"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/CamShaft/startup.git"
+ },
+ "keywords": [
+ "app",
+ "runner",
+ "express",
+ "connect",
+ "http"
+ ],
+ "author": "Cameron Bytheway <cameron@nujii.com>",
+ "license": "MIT",
+ "readmeFilename": "README.md",
+ "dependencies": {
+ "commander": "~1.1.1",
+ "cli-table": "~0.2.0"
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.