forked from cutting-room-floor/tilestream
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtilestream.js
47 lines (39 loc) · 1.35 KB
/
tilestream.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
require.paths.splice(0, require.paths.length);
require.paths.unshift(
__dirname + '/lib/node',
__dirname + '/server',
__dirname + '/mvc',
__dirname
);
// Bootstrap.
require('bootstrap')(require('settings'));
var _ = require('underscore'),
express = require('express'),
settings = require('settings'),
tile_server = express.createServer(),
ui_server = settings.UIPort === settings.port ? tile_server : express.createServer();
ui_server.use(express.staticProvider('client'));
ui_server.use(express.staticProvider('mvc'));
ui_server.use(express.staticProvider('modules'));
ui_server.enable('jsonp callback');
tile_server.enable('jsonp callback');
// Initialize bones, apply overrides/mixins and other setup.
require('bones').Bones(ui_server);
require('models-server');
require('templates')(settings);
// Main server modules.
require('tile-server')(tile_server, settings);
require('ui-server')(ui_server, settings);
require('wax')(ui_server, settings);
if (tile_server.settings.env !== 'test') {
tile_server.listen(settings.port);
console.log('Started TileStream on port %d.', settings.port);
if (settings.UIPort !== settings.port) {
ui_server.listen(settings.UIPort);
console.log('Started TileStream UI on port %d.', settings.UIPort);
}
}
module.exports = {
tile_server: tile_server,
ui_server: ui_server
};