mirror of
https://github.com/openstf/stf
synced 2025-10-04 10:19:30 +02:00
Error if unable to resolve endpoints.
This commit is contained in:
parent
2f8116dfe6
commit
eb841161ac
6 changed files with 66 additions and 24 deletions
|
@ -12,7 +12,8 @@ module.exports = syrup.serial()
|
|||
|
||||
// Output
|
||||
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.attempt(records, function(record) {
|
||||
log.info('Sending output to "%s"', record.url)
|
||||
|
@ -21,6 +22,5 @@ module.exports = syrup.serial()
|
|||
})
|
||||
})
|
||||
})
|
||||
|
||||
return push
|
||||
.return(push)
|
||||
})
|
||||
|
|
|
@ -6,6 +6,7 @@ var Promise = require('bluebird')
|
|||
var logger = require('../../../util/logger')
|
||||
var wireutil = require('../../../wire/util')
|
||||
var srv = require('../../../util/srv')
|
||||
var lifecycle = require('../../../util/lifecycle')
|
||||
|
||||
module.exports = syrup.serial()
|
||||
.define(function(options) {
|
||||
|
@ -13,7 +14,8 @@ module.exports = syrup.serial()
|
|||
|
||||
// Input
|
||||
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.attempt(records, function(record) {
|
||||
log.info('Receiving input from "%s"', record.url)
|
||||
|
@ -22,12 +24,12 @@ module.exports = syrup.serial()
|
|||
})
|
||||
})
|
||||
})
|
||||
|
||||
.then(function() {
|
||||
// Establish always-on channels
|
||||
;[wireutil.global].forEach(function(channel) {
|
||||
log.info('Subscribing to permanent channel "%s"', channel)
|
||||
sub.subscribe(channel)
|
||||
})
|
||||
|
||||
return sub
|
||||
})
|
||||
.return(sub)
|
||||
})
|
||||
|
|
|
@ -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) {
|
||||
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()
|
||||
// Provider messages
|
||||
|
|
|
@ -81,6 +81,10 @@ module.exports = function(options) {
|
|||
})
|
||||
})
|
||||
})
|
||||
.catch(function(err) {
|
||||
log.fatal('Unable to connect to push endpoint', err)
|
||||
lifecycle.fatal()
|
||||
})
|
||||
|
||||
// Input
|
||||
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
|
||||
;[solo].forEach(function(channel) {
|
||||
|
|
|
@ -27,6 +27,10 @@ module.exports = function(options) {
|
|||
})
|
||||
})
|
||||
})
|
||||
.catch(function(err) {
|
||||
log.fatal('Unable to connect to push endpoint', err)
|
||||
lifecycle.fatal()
|
||||
})
|
||||
|
||||
function reap() {
|
||||
dbapi.getDeadDevices(options.heartbeatTimeout)
|
||||
|
|
|
@ -16,6 +16,7 @@ var wirerouter = require('../../wire/router')
|
|||
var dbapi = require('../../db/api')
|
||||
var datautil = require('../../util/datautil')
|
||||
var srv = require('../../util/srv')
|
||||
var lifecycle = require('../../util/lifecycle')
|
||||
var cookieSession = require('./middleware/cookie-session')
|
||||
var ip = require('./middleware/remote-ip')
|
||||
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
|
||||
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
|
||||
;[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)
|
||||
log.info('Listening on port %d', options.port)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue