mirror of
https://github.com/openstf/stf
synced 2025-10-04 10:19:30 +02:00
Fix issues with the proxy.
This commit is contained in:
parent
8bc9592a79
commit
88de7d1578
2 changed files with 14 additions and 6 deletions
|
@ -40,7 +40,7 @@ program
|
||||||
, 'maximum port number for worker use'
|
, 'maximum port number for worker use'
|
||||||
, Number
|
, Number
|
||||||
, 7800)
|
, 7800)
|
||||||
.option('--public-ip'
|
.option('--public-ip <ip>'
|
||||||
, 'public ip for global access'
|
, 'public ip for global access'
|
||||||
, String
|
, String
|
||||||
, ip())
|
, ip())
|
||||||
|
|
|
@ -181,6 +181,15 @@ module.exports = function(options) {
|
||||||
.then(function() {
|
.then(function() {
|
||||||
var resolver = Promise.defer()
|
var resolver = Promise.defer()
|
||||||
|
|
||||||
|
function resolve() {
|
||||||
|
vitals.register('device:http:proxy', proxyServer)
|
||||||
|
resolver.resolve()
|
||||||
|
}
|
||||||
|
|
||||||
|
function reject(err) {
|
||||||
|
resolver.reject(err)
|
||||||
|
}
|
||||||
|
|
||||||
var proxy = httpProxy.createProxyServer({
|
var proxy = httpProxy.createProxyServer({
|
||||||
target: url
|
target: url
|
||||||
, ws: false
|
, ws: false
|
||||||
|
@ -190,13 +199,12 @@ module.exports = function(options) {
|
||||||
var proxyServer = http.createServer(proxy.web)
|
var proxyServer = http.createServer(proxy.web)
|
||||||
.listen(everyones)
|
.listen(everyones)
|
||||||
|
|
||||||
proxyServer.on('listening', resolver.resolve)
|
proxyServer.on('listening', resolve)
|
||||||
proxyServer.on('error', resolver.reject)
|
proxyServer.on('error', reject)
|
||||||
|
|
||||||
return resolver.promise.finally(function() {
|
return resolver.promise.finally(function() {
|
||||||
proxyServer.removeListener('listening', resolver.resolve)
|
proxyServer.removeListener('listening', resolve)
|
||||||
proxyServer.removeListener('error', resolver.reject)
|
proxyServer.removeListener('error', reject)
|
||||||
vitals.add('device:http:proxy', proxyServer)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.then(function() {
|
.then(function() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue