Created
May 25, 2017 23:35
-
-
Save podviaznikov/669f746e3f73c2119bcbad8c2b26b8a5 to your computer and use it in GitHub Desktop.
error handling on the workers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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