1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-03 17:59:28 +02:00

Fix issues with the proxy.

This commit is contained in:
Simo Kinnunen 2014-01-30 19:36:43 +09:00
parent 8bc9592a79
commit 88de7d1578
2 changed files with 14 additions and 6 deletions

View file

@ -40,7 +40,7 @@ program
, 'maximum port number for worker use'
, Number
, 7800)
.option('--public-ip'
.option('--public-ip <ip>'
, 'public ip for global access'
, String
, ip())

View file

@ -181,6 +181,15 @@ module.exports = function(options) {
.then(function() {
var resolver = Promise.defer()
function resolve() {
vitals.register('device:http:proxy', proxyServer)
resolver.resolve()
}
function reject(err) {
resolver.reject(err)
}
var proxy = httpProxy.createProxyServer({
target: url
, ws: false
@ -190,13 +199,12 @@ module.exports = function(options) {
var proxyServer = http.createServer(proxy.web)
.listen(everyones)
proxyServer.on('listening', resolver.resolve)
proxyServer.on('error', resolver.reject)
proxyServer.on('listening', resolve)
proxyServer.on('error', reject)
return resolver.promise.finally(function() {
proxyServer.removeListener('listening', resolver.resolve)
proxyServer.removeListener('error', resolver.reject)
vitals.add('device:http:proxy', proxyServer)
proxyServer.removeListener('listening', resolve)
proxyServer.removeListener('error', reject)
})
})
.then(function() {