Commit 137646e5 authored by Leo Iannacone's avatar Leo Iannacone

upgrade to express 4.x

parent b23b30bf
#!/usr/bin/env nodejs
'use strict';
/**
* Module dependencies.
*/
var express = require('express')
, routes = require('./routes')
, config = require('./lib/config.js')
, utils = require('./lib/utils.js')
, http = require('http')
, app = module.exports = express()
, Client = require('./lib/client.js')
, Broadcaster = require('./lib/broadcaster.js')
var express = require('express'),
serve_static = require('serve-static'),
serve_index = require('serve-index'),
errorhandler = require('errorhandler'),
routes = require('./routes'),
config = require('./lib/config.js'),
utils = require('./lib/utils.js'),
http = require('http'),
app = module.exports = express(),
Client = require('./lib/client.js'),
Broadcaster = require('./lib/broadcaster.js');
// Configuration
app.configure(function(){
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.use(express.json());
app.use(express.urlencoded());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(__dirname + '/public'));
app.use(config.routes.debomatic, express.directory(config.debomatic.path));
app.use(config.routes.debomatic, express.static(config.debomatic.path));
//app.enable('trust proxy');
});
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.use(serve_static(__dirname + '/public'));
app.use(config.routes.debomatic, serve_index(config.debomatic.path));
app.use(config.routes.debomatic, serve_static(config.debomatic.path));
app.configure('development', function(){
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});
app.configure('production', function(){
app.use(express.errorHandler());
});
var env = process.env.NODE_ENV || 'development';
if ('development' == env) {
app.use(errorhandler({
dumpExceptions: true,
showStack: true
}));
} else if ('development' == env) {
app.use(errorhandler());
}
// Routes
app.get('/', routes.index);
app.get(config.routes.distribution, routes.distribution)
app.get(config.routes.distribution, routes.distribution);
if (config.routes.preferences)
app.get(config.routes.preferences, routes.preferences)
app.get(config.routes.preferences, routes.preferences);
var server = http.createServer(app)
, io = require('socket.io').listen(server, config.socket)
var server = http.createServer(app),
io = require('socket.io').listen(server, config.socket);
// Listening
server.listen(config.port, config.host, null, function(err){
server.listen(config.port, config.host, null, function (err) {
// Checking nodejs with sudo:
// Find out which user used sudo through the environment variable
// and set his user id
var uid = parseInt(process.env.SUDO_UID);
if (uid) {
console.log("Please do not run nodejs with sudo. Changing user to %d", uid)
process.setgid(uid);
process.setuid(uid);
}
// Checking nodejs with sudo:
// Find out which user used sudo through the environment variable
// and set his user id
var uid = parseInt(process.env.SUDO_UID);
if (uid) {
console.log('Please do not run nodejs with sudo. Changing user to %d', uid);
process.setgid(uid);
process.setuid(uid);
}
// statuses
var status = []
// statuses
var status = [];
var broadcast = new Broadcaster(io.sockets, status)
var broadcast = new Broadcaster(io.sockets, status);
io.sockets.on('connection', function(socket) {
var client = new Client(socket)
client.start()
if (status.length > 0)
client.send_status(status)
});
io.sockets.on('connection', function (socket) {
var client = new Client(socket);
client.start();
if (status.length > 0)
client.send_status(status);
});
console.log("Debomatic-webui listening on %s:%d in %s mode", server.address().address, server.address().port, app.settings.env);
console.log('Debomatic-webui listening on %s:%d in %s mode', server.address().address, server.address().port, app.settings.env);
});
server.on('error', function (e) {
if (e.code == 'EADDRINUSE') {
console.log('Address in use %s:%d. Exit.', config.host, config.port);
process.exit(1);
}
else {
console.error(e);
}
if (e.code == 'EADDRINUSE') {
console.log('Address in use %s:%d. Exit.', config.host, config.port);
process.exit(1);
} else {
console.error(e);
}
});
{
"name": "debomatic-webui"
, "version": "0.0.1"
, "private": true
, "dependencies": {
"express": "3.x"
, "ejs": ">= 0.0.1"
, "socket.io": "*"
, "tail": "*"
}
, "scripts": {
"install": "bash scripts/install.sh"
}
"name": "debomatic-webui",
"version": "0.0.1",
"private": true,
"dependencies": {
"express": "4.x",
"serve-index": "*",
"serve-static": "*",
"errorhandler ": "*",
"ejs": ">= 0.0.1",
"socket.io": "0.*",
"tail": "*"
},
"scripts": {
"install": "bash scripts/install.sh"
}
}
#!/bin/bash
CSS="${SCRIPTS_DIR}/../node_modules/express/node_modules/connect/node_modules/serve-index/public/style.css"
CSS="${SCRIPTS_DIR}/../node_modules/serve-index/public/style.css"
if [ "`grep debomatic-webui $CSS`" == "" ] ; then
echo "Patching directory listing style.css"
cp $CSS $CSS.orig
echo "
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment