mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 07:56:16 -04:00
Differentiate between http server and express app
This commit is contained in:
parent
c8b6d3b4f3
commit
4416210471
3 changed files with 11 additions and 8 deletions
|
@ -54,7 +54,8 @@ Called from: src/node/server.js
|
||||||
|
|
||||||
Things in context:
|
Things in context:
|
||||||
|
|
||||||
1. app - the main application object (helpful for adding new paths and such)
|
1. app - the main express application object (helpful for adding new paths and such)
|
||||||
|
1. server - the http server object
|
||||||
|
|
||||||
This hook gets called after the application object has been created, but before it starts listening. This is similar to the expressConfigure hook, but it's not guaranteed that the application object will have all relevant configuration variables.
|
This hook gets called after the application object has been created, but before it starts listening. This is similar to the expressConfigure hook, but it's not guaranteed that the application object will have all relevant configuration variables.
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
var hooks = require("ep_etherpad-lite/static/js/pluginfw/hooks");
|
var hooks = require("ep_etherpad-lite/static/js/pluginfw/hooks");
|
||||||
|
var http = require('http');
|
||||||
var express = require('express');
|
var express = require('express');
|
||||||
var settings = require('../utils/Settings');
|
var settings = require('../utils/Settings');
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
|
@ -48,17 +49,18 @@ exports.restartServer = function () {
|
||||||
server.close();
|
server.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
server = express(); // New syntax for express v3
|
var app = express(); // New syntax for express v3
|
||||||
|
server = http.createServer(app);
|
||||||
|
|
||||||
server.use(function (req, res, next) {
|
app.use(function (req, res, next) {
|
||||||
res.header("Server", serverName);
|
res.header("Server", serverName);
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
|
||||||
server.configure(function() {
|
app.configure(function() {
|
||||||
hooks.callAll("expressConfigure", {"app": server});
|
hooks.callAll("expressConfigure", {"app": app});
|
||||||
});
|
});
|
||||||
hooks.callAll("expressCreateServer", {"app": server});
|
hooks.callAll("expressCreateServer", {"app": app, "server": server});
|
||||||
|
|
||||||
server.listen(settings.port, settings.ip);
|
server.listen(settings.port, settings.ip);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ var connect = require('connect');
|
||||||
|
|
||||||
exports.expressCreateServer = function (hook_name, args, cb) {
|
exports.expressCreateServer = function (hook_name, args, cb) {
|
||||||
//init socket.io and redirect all requests to the MessageHandler
|
//init socket.io and redirect all requests to the MessageHandler
|
||||||
var io = socketio.listen(args.app);
|
var io = socketio.listen(args.server);
|
||||||
|
|
||||||
/* Require an express session cookie to be present, and load the
|
/* Require an express session cookie to be present, and load the
|
||||||
* session. See http://www.danielbaulig.de/socket-ioexpress for more
|
* session. See http://www.danielbaulig.de/socket-ioexpress for more
|
||||||
|
@ -62,5 +62,5 @@ exports.expressCreateServer = function (hook_name, args, cb) {
|
||||||
socketIORouter.setSocketIO(io);
|
socketIORouter.setSocketIO(io);
|
||||||
socketIORouter.addComponent("pad", padMessageHandler);
|
socketIORouter.addComponent("pad", padMessageHandler);
|
||||||
|
|
||||||
hooks.callAll("socketio", {"app": args.app, "io": io});
|
hooks.callAll("socketio", {"app": args.app, "io": io, "server": args.server});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue