forked from bee-queue/arena
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
29 lines (21 loc) · 938 Bytes
/
index.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
const express = require('express');
const fs = require('fs');
const path = require('path');
const Arena = require('./src/server/app');
const routes = require('./src/server/views/routes');
function run(config, listenOpts = {}) {
const {app, Queues} = Arena();
if (config) Queues.setConfig(config);
Queues.useCdn = typeof listenOpts.useCdn !== 'undefined' ? listenOpts.useCdn : true;
app.locals.appBasePath = listenOpts.basePath || app.locals.appBasePath;
app.use(app.locals.appBasePath, express.static(path.join(__dirname, 'public')));
app.use(app.locals.appBasePath, routes);
const port = listenOpts.port || 4567;
const host= listenOpts.host || '0.0.0.0'; // Default: listen to all network interfaces.
if (!listenOpts.disableListen) {
app.listen(port, host, () => console.log(`Arena is running on port ${port} at host ${host}`));
}
return app;
}
if (require.main === module) run();
module.exports = run;