Skip to content
Browse files

Initial commit

  • Loading branch information...
0 parents commit d06261e1718c1d53a4f4b3b81044d6ec99fd7a81 @mekwall committed Jan 2, 2013
Showing with 278 additions and 0 deletions.
  1. +13 −0 .gitignore
  2. +7 −0 .npmignore
  3. +9 −0 LICENSE.txt
  4. +3 −0 README.md
  5. +62 −0 bin/overseer
  6. +1 −0 index.js
  7. +38 −0 package.json
  8. +105 −0 src/logger.js
  9. +40 −0 src/overseer.js
13 .gitignore
@@ -0,0 +1,13 @@
+lib-cov
+*.seed
+*.log
+*.csv
+*.dat
+*.out
+*.pid
+*.gz
+pids
+logs
+results
+node_modules
+npm-debug.log
7 .npmignore
@@ -0,0 +1,7 @@
+.git*
+docs/
+examples/
+support/
+test/
+testing.js
+.DS_Store
9 LICENSE.txt
@@ -0,0 +1,9 @@
+Copyright (c) 2010-2012 Marcus Ekwall
+
+The MIT License
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3 README.md
@@ -0,0 +1,3 @@
+# express-assets
+
+More info coming soon.
62 bin/overseer
@@ -0,0 +1,62 @@
+#!/usr/bin/env node
+
+// windows: running "overseer blah" in this folder will invoke WSH, not node.
+if (typeof WScript !== "undefined") {
+ WScript.echo("overseer does not work when run\n"
+ +"with the Windows Scripting Host\n\n"
+ +"'cd' to a different directory,\n"
+ +"or type 'overseer.cmd <args>',\n"
+ +"or type 'node overseer <args>'.");
+ WScript.quit(1);
+ return
+}
+
+process.title = "overseer";
+
+// Module deps
+const exec = require('child_process').exec;
+const program = require('commander');
+const pkg = require('../package.json');
+const version = pkg.version;
+const os = require('os');
+const fs = require('fs');
+const path = require('path');
+const overseer = require('../src/overseer');
+
+// CLI
+program
+ .version(version)
+ .usage('[options] <file>')
+ .option('-w, --watch', 'watch for file system changes')
+ .option('-f, --forks <n>', 'amount of workers to fork')
+ .option('-P, --port <port>', 'port to listen to')
+ .option('-H, --hostname <hostname>', 'hostname to listen to')
+ .option('-E, --env <environment>', 'set environment')
+ .option('--pidfile <file>', 'pidfile to use')
+ .on('--help', function(){
+ console.log(' Examples:');
+ console.log('');
+ console.log(' $ overseer -w -P 61337 -H localhost -f 4 app.js');
+ console.log('');
+ })
+ .parse(process.argv);
+
+const ENV = program.env || (process.env["NODE_ENV"] || "development");
+const PORT = program.port || (process.env["PORT"] || 3000);
+const HOST = program.hostname || (process.env["HOSTNAME"] || "0.0.0.0");
+
+// Path
+var appFile = program.args.shift();
+
+if (!appFile) {
+ console.error("Error: Missing file argument. -h for help");
+ process.exit(0);
+}
+
+appFile = path.resolve(appFile);
+if (!fs.existsSync(appFile)) {
+ console.error("Error: %s could not be found.", appFile);
+ process.exit(0);
+}
+
+console.log(appfile);
1 index.js
@@ -0,0 +1 @@
+module.exports = require("./src/overseer");
38 package.json
@@ -0,0 +1,38 @@
+{
+ "name": "overseer",
+ "description": "",
+ "version": "0.1.0",
+ "authors": [
+ {
+ "name": "Marcus Ekwall",
+ "email": "marcus.ekwall@gmail.com",
+ "web": "http://www.writeless.se"
+ }
+ ],
+ "licenses": [
+ {
+ "type": "MIT",
+ "url": "http://opensource.org/licenses/mit-license.php"
+ }
+ ],
+ "bugs": {
+ "url": "git://github.com/mekwall/overseer/issues"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/mekwall/overseer.git"
+ },
+ "engines": {
+ "node": "~0.8.16"
+ },
+ "main": "index",
+ "bin": {
+ "overseer": "./bin/overseer"
+ },
+ "dependencies": {
+ "cli-color": "~0.2.1",
+ "keypress": "~0.1.0",
+ "commander": "~1.1.1",
+ "watch": "~0.5.1"
+ }
+}
105 src/logger.js
@@ -0,0 +1,105 @@
+const clr = require("cli-color");
+
+var logger = {};
+
+logger.timestamp = function(ret) {
+ var date = (new Date);
+ var seconds = ""+date.getSeconds();
+ var minutes = ""+date.getMinutes();
+ var hours = ""+date.getHours();
+
+ if (hours.length === 1) {
+ hours = "0" + hours;
+ }
+
+ if (minutes.length === 1) {
+ minutes = "0" + minutes;
+ }
+
+ if (seconds.length === 1) {
+ seconds = "0" + seconds;
+ }
+
+ if (ret) {
+ return { hours: hours, minutes: minutes, seconds: seconds };
+ } else {
+ process.stdout.write(" "+hours+":"+minutes+" ");
+ }
+}
+
+logger.log = function () {
+ this.timestamp();
+ process.stdout.write(clc.white(" log "));
+ if (this._org && this._org.log) {
+ this._org.log.apply(this, arguments);
+ } else {
+ console.log.apply(console, arguments);
+ }
+};
+
+logger.error = function () {
+ this.timestamp();
+ process.stdout.write(clc.red.bold(" error "));
+ orgcon.error.apply(this, arguments);
+ if (this._org && this._org.error) {
+ this._org.error.apply(this, arguments);
+ } else {
+ console.error.apply(console, arguments);
+ }
+};
+
+logger.info = function () {
+ if (ENV !== "development") return;
+ this.timestamp();
+ process.stdout.write(clc.cyan(" info "));
+ if (this._org && this._org.warn) {
+ this._org.info.apply(this, arguments);
+ } else {
+ console.info.apply(console, arguments);
+ }
+};
+
+logger.warn = function () {
+ this.timestamp();
+ process.stdout.write(clc.yellow(" warn "));
+ if (this._org && this._org.warn) {
+ this._org.warn.apply(this, arguments);
+ } else {
+ console.warn.apply(console, arguments);
+ }
+};
+
+logger.debug = function () {
+ if (ENV !== "development") return;
+ this.timestamp();
+ process.stdout.write(clc.yellow.bold(" debug "));
+ if (this._org && this._org.log) {
+ this._org.log.apply(this, arguments);
+ } else {
+ console.log.apply(console, arguments);
+ }
+};
+
+module.exports = function (org) {
+ if (org) {
+ org._org = {
+ log: org.log,
+ error: org.error,
+ info: org.info,
+ warn: org.warn
+ };
+ org._restore = function () {
+ for (var fn in org._org) {
+ org[fn] = org._org[f];
+ }
+ delete org._org;
+ delete org._restore;
+ }
+
+ for (var fn in logger) {
+ org[fn] = logger[fn];
+ }
+ return org;
+ }
+ return logger;
+}
40 src/overseer.js
@@ -0,0 +1,40 @@
+// Module dependencies
+const pkg = require("../package.json");
+const cluster = require("cluster");
+
+// Replace console
+console = require("./logger")(console);
+
+// Make sure this is the master
+if (!cluster.isMaster) {
+ console.log("overseer can only be run as master");
+ process.exit(0);
+}
+
+var overseer = {};
+
+overseer.run = function() {
+ process.stdout.write(banner);
+};
+
+// Cool ascii art banner
+var banner = "\n"+
+" _____ _____ _ __ ___ ___ ___ _ __ \n"+
+" / _ \\ \\ / / _ \\ '__/ __|/ _ \\/ _ \\ '__|\n"+
+"| (_) \\ V / __/ | \\__ \\ __/ __/ | \n"+
+" \\___/ \\_/ \\___|_| |___/\\___|\\___|_| \n"+
+" \n";
+
+module.exports = function () {
+ if (arguments.length) {
+ if (typeof arguments[0] === "object") {
+ var options = arguments[0];
+ } else if (typeof arguments[0] === "string") {
+ var file = arguments[1];
+ if (arguments[1] && typeof arguments[1] === "object") {
+
+ }
+ }
+ }
+ overseer;
+};

0 comments on commit d06261e

Please sign in to comment.
Something went wrong with that request. Please try again.