Skip to content

Instantly share code, notes, and snippets.

@podviaznikov
Created May 25, 2017 23:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save podviaznikov/669f746e3f73c2119bcbad8c2b26b8a5 to your computer and use it in GitHub Desktop.
Save podviaznikov/669f746e3f73c2119bcbad8c2b26b8a5 to your computer and use it in GitHub Desktop.
error handling on the workers
onContainerDataSaved = function (container) {
let networkData
try {
networkData = network.fetchNetworkData()
network.attachContainerToNetwork(networkData, container)
websockets.sendErrorToClients("Cannot attach container to the network")
} catch (err) {
if (err instanceof NetworkAttachError) {
messageBus.emit('network.attach.failed', { container, networkData })
}
}
}
// we can set in configuration the retry policy for such worker: exponential back-off, timeout, max number of retries etc,
onNetworkAttachFailed = function (container, networkData) {
docker.removeContainer(container)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment