mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
feature(server) add prefix to url
This commit is contained in:
parent
42ed9c70e2
commit
c473a25a48
1 changed files with 10 additions and 4 deletions
|
|
@ -14,7 +14,10 @@
|
|||
freeport = require('freeport'),
|
||||
tryRequire = require('tryrequire'),
|
||||
logger = tryRequire('morgan'),
|
||||
io = require('socket.io');
|
||||
io = require('socket.io'),
|
||||
squad = require('squad'),
|
||||
apart = require('apart'),
|
||||
prefix = squad(prefixer, apart(config, 'prefix'));
|
||||
|
||||
/**
|
||||
* start server function
|
||||
|
|
@ -32,7 +35,7 @@
|
|||
config('ip') ||
|
||||
'0.0.0.0',
|
||||
|
||||
app = express();
|
||||
app = express();
|
||||
|
||||
server = http.createServer(app);
|
||||
|
||||
|
|
@ -42,7 +45,7 @@
|
|||
app.use(cloudcmd({
|
||||
config: options,
|
||||
socket: io(server, {
|
||||
path: prefixer(config('prefix')) + '/socket.io'
|
||||
path: prefix() + '/socket.io'
|
||||
})
|
||||
}));
|
||||
|
||||
|
|
@ -58,13 +61,16 @@
|
|||
};
|
||||
|
||||
getPort(function(error, port) {
|
||||
var url = config('ip') || 'localhost' + prefix();
|
||||
|
||||
if (error)
|
||||
return onError(error);
|
||||
|
||||
server.listen(port, ip);
|
||||
server.on('error', onError);
|
||||
|
||||
console.log('url: http://%s:%d', config('ip') || 'localhost', port);
|
||||
console.log('url: http://%s:%d', url, port);
|
||||
});
|
||||
};
|
||||
})();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue