1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-04 18:29:17 +02:00

Error if unable to resolve endpoints.

This commit is contained in:
Simo Kinnunen 2014-12-18 16:29:15 +09:00
parent 2f8116dfe6
commit eb841161ac
6 changed files with 66 additions and 24 deletions

View file

@ -12,7 +12,8 @@ module.exports = syrup.serial()
// Output // Output
var push = zmq.socket('push') var push = zmq.socket('push')
Promise.map(options.endpoints.push, function(endpoint) {
return Promise.map(options.endpoints.push, function(endpoint) {
return srv.resolve(endpoint).then(function(records) { return srv.resolve(endpoint).then(function(records) {
return srv.attempt(records, function(record) { return srv.attempt(records, function(record) {
log.info('Sending output to "%s"', record.url) log.info('Sending output to "%s"', record.url)
@ -21,6 +22,5 @@ module.exports = syrup.serial()
}) })
}) })
}) })
.return(push)
return push
}) })

View file

@ -6,6 +6,7 @@ var Promise = require('bluebird')
var logger = require('../../../util/logger') var logger = require('../../../util/logger')
var wireutil = require('../../../wire/util') var wireutil = require('../../../wire/util')
var srv = require('../../../util/srv') var srv = require('../../../util/srv')
var lifecycle = require('../../../util/lifecycle')
module.exports = syrup.serial() module.exports = syrup.serial()
.define(function(options) { .define(function(options) {
@ -13,7 +14,8 @@ module.exports = syrup.serial()
// Input // Input
var sub = zmq.socket('sub') var sub = zmq.socket('sub')
Promise.map(options.endpoints.sub, function(endpoint) {
return Promise.map(options.endpoints.sub, function(endpoint) {
return srv.resolve(endpoint).then(function(records) { return srv.resolve(endpoint).then(function(records) {
return srv.attempt(records, function(record) { return srv.attempt(records, function(record) {
log.info('Receiving input from "%s"', record.url) log.info('Receiving input from "%s"', record.url)
@ -22,12 +24,12 @@ module.exports = syrup.serial()
}) })
}) })
}) })
.then(function() {
// Establish always-on channels // Establish always-on channels
;[wireutil.global].forEach(function(channel) { ;[wireutil.global].forEach(function(channel) {
log.info('Subscribing to permanent channel "%s"', channel) log.info('Subscribing to permanent channel "%s"', channel)
sub.subscribe(channel) sub.subscribe(channel)
}) })
})
return sub .return(sub)
}) })

View file

@ -27,6 +27,10 @@ module.exports = function(options) {
}) })
}) })
}) })
.catch(function(err) {
log.fatal('Unable to connect to app dealer endpoint', err)
lifecycle.fatal()
})
appDealer.on('message', function(channel, data) { appDealer.on('message', function(channel, data) {
devDealer.send([channel, data]) devDealer.send([channel, data])
@ -43,6 +47,10 @@ module.exports = function(options) {
}) })
}) })
}) })
.catch(function(err) {
log.fatal('Unable to connect to dev dealer endpoint', err)
lifecycle.fatal()
})
devDealer.on('message', wirerouter() devDealer.on('message', wirerouter()
// Provider messages // Provider messages

View file

@ -81,6 +81,10 @@ module.exports = function(options) {
}) })
}) })
}) })
.catch(function(err) {
log.fatal('Unable to connect to push endpoint', err)
lifecycle.fatal()
})
// Input // Input
var sub = zmq.socket('sub') var sub = zmq.socket('sub')
@ -93,6 +97,10 @@ module.exports = function(options) {
}) })
}) })
}) })
.catch(function(err) {
log.fatal('Unable to connect to sub endpoint', err)
lifecycle.fatal()
})
// Establish always-on channels // Establish always-on channels
;[solo].forEach(function(channel) { ;[solo].forEach(function(channel) {

View file

@ -27,6 +27,10 @@ module.exports = function(options) {
}) })
}) })
}) })
.catch(function(err) {
log.fatal('Unable to connect to push endpoint', err)
lifecycle.fatal()
})
function reap() { function reap() {
dbapi.getDeadDevices(options.heartbeatTimeout) dbapi.getDeadDevices(options.heartbeatTimeout)

View file

@ -16,6 +16,7 @@ var wirerouter = require('../../wire/router')
var dbapi = require('../../db/api') var dbapi = require('../../db/api')
var datautil = require('../../util/datautil') var datautil = require('../../util/datautil')
var srv = require('../../util/srv') var srv = require('../../util/srv')
var lifecycle = require('../../util/lifecycle')
var cookieSession = require('./middleware/cookie-session') var cookieSession = require('./middleware/cookie-session')
var ip = require('./middleware/remote-ip') var ip = require('./middleware/remote-ip')
var auth = require('./middleware/auth') var auth = require('./middleware/auth')
@ -40,6 +41,10 @@ module.exports = function(options) {
}) })
}) })
}) })
.catch(function(err) {
log.fatal('Unable to connect to push endpoint', err)
lifecycle.fatal()
})
// Input // Input
var sub = zmq.socket('sub') var sub = zmq.socket('sub')
@ -52,6 +57,10 @@ module.exports = function(options) {
}) })
}) })
}) })
.catch(function(err) {
log.fatal('Unable to connect to sub endpoint', err)
lifecycle.fatal()
})
// Establish always-on channels // Establish always-on channels
;[wireutil.global].forEach(function(channel) { ;[wireutil.global].forEach(function(channel) {
@ -818,6 +827,17 @@ module.exports = function(options) {
}) })
}) })
lifecycle.observe(function() {
[push, sub].forEach(function(sock) {
try {
sock.close()
}
catch (err) {
// No-op
}
})
})
server.listen(options.port) server.listen(options.port)
log.info('Listening on port %d', options.port) log.info('Listening on port %d', options.port)
} }