mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 05:13:43 -05:00
Decaf cleanup: remove default callbacks
This commit is contained in:
parent
32f0bbe266
commit
ee4c08868c
1 changed files with 6 additions and 31 deletions
|
@ -50,9 +50,6 @@ module.exports = DockerRunner = {
|
||||||
callback
|
callback
|
||||||
) {
|
) {
|
||||||
let name
|
let name
|
||||||
if (callback == null) {
|
|
||||||
callback = function (error, output) {}
|
|
||||||
}
|
|
||||||
if (usingSiblingContainers()) {
|
if (usingSiblingContainers()) {
|
||||||
const _newPath = Settings.path.sandboxedCompilesHostDir
|
const _newPath = Settings.path.sandboxedCompilesHostDir
|
||||||
logger.log(
|
logger.log(
|
||||||
|
@ -135,9 +132,6 @@ module.exports = DockerRunner = {
|
||||||
},
|
},
|
||||||
|
|
||||||
kill(container_id, callback) {
|
kill(container_id, callback) {
|
||||||
if (callback == null) {
|
|
||||||
callback = function (error) {}
|
|
||||||
}
|
|
||||||
logger.log({ container_id }, 'sending kill signal to container')
|
logger.log({ container_id }, 'sending kill signal to container')
|
||||||
const container = dockerode.getContainer(container_id)
|
const container = dockerode.getContainer(container_id)
|
||||||
container.kill(function (error) {
|
container.kill(function (error) {
|
||||||
|
@ -162,9 +156,6 @@ module.exports = DockerRunner = {
|
||||||
},
|
},
|
||||||
|
|
||||||
_runAndWaitForContainer(options, volumes, timeout, _callback) {
|
_runAndWaitForContainer(options, volumes, timeout, _callback) {
|
||||||
if (_callback == null) {
|
|
||||||
_callback = function (error, output) {}
|
|
||||||
}
|
|
||||||
const callback = function (...args) {
|
const callback = function (...args) {
|
||||||
_callback(...args)
|
_callback(...args)
|
||||||
// Only call the callback once
|
// Only call the callback once
|
||||||
|
@ -366,9 +357,6 @@ module.exports = DockerRunner = {
|
||||||
|
|
||||||
// Check that volumes exist and are directories
|
// Check that volumes exist and are directories
|
||||||
_checkVolumes(options, volumes, callback) {
|
_checkVolumes(options, volumes, callback) {
|
||||||
if (callback == null) {
|
|
||||||
callback = function (error, containerName) {}
|
|
||||||
}
|
|
||||||
if (usingSiblingContainers()) {
|
if (usingSiblingContainers()) {
|
||||||
// Server Pro, with sibling-containers active, skip checks
|
// Server Pro, with sibling-containers active, skip checks
|
||||||
return callback(null)
|
return callback(null)
|
||||||
|
@ -392,9 +380,6 @@ module.exports = DockerRunner = {
|
||||||
},
|
},
|
||||||
|
|
||||||
_startContainer(options, volumes, attachStreamHandler, callback) {
|
_startContainer(options, volumes, attachStreamHandler, callback) {
|
||||||
if (callback == null) {
|
|
||||||
callback = function (error, output) {}
|
|
||||||
}
|
|
||||||
callback = _.once(callback)
|
callback = _.once(callback)
|
||||||
const { name } = options
|
const { name } = options
|
||||||
|
|
||||||
|
@ -510,9 +495,6 @@ module.exports = DockerRunner = {
|
||||||
},
|
},
|
||||||
|
|
||||||
waitForContainer(containerId, timeout, _callback) {
|
waitForContainer(containerId, timeout, _callback) {
|
||||||
if (_callback == null) {
|
|
||||||
_callback = function (error, exitCode) {}
|
|
||||||
}
|
|
||||||
const callback = function (...args) {
|
const callback = function (...args) {
|
||||||
_callback(...args)
|
_callback(...args)
|
||||||
// Only call the callback once
|
// Only call the callback once
|
||||||
|
@ -564,9 +546,6 @@ module.exports = DockerRunner = {
|
||||||
// async exception, but if you delete by id it just does a normal
|
// async exception, but if you delete by id it just does a normal
|
||||||
// error callback. We fall back to deleting by name if no id is
|
// error callback. We fall back to deleting by name if no id is
|
||||||
// supplied.
|
// supplied.
|
||||||
if (callback == null) {
|
|
||||||
callback = function (error) {}
|
|
||||||
}
|
|
||||||
LockManager.runWithLock(
|
LockManager.runWithLock(
|
||||||
containerName,
|
containerName,
|
||||||
(releaseLock) =>
|
(releaseLock) =>
|
||||||
|
@ -580,9 +559,6 @@ module.exports = DockerRunner = {
|
||||||
},
|
},
|
||||||
|
|
||||||
_destroyContainer(containerId, shouldForce, callback) {
|
_destroyContainer(containerId, shouldForce, callback) {
|
||||||
if (callback == null) {
|
|
||||||
callback = function (error) {}
|
|
||||||
}
|
|
||||||
logger.log({ container_id: containerId }, 'destroying docker container')
|
logger.log({ container_id: containerId }, 'destroying docker container')
|
||||||
const container = dockerode.getContainer(containerId)
|
const container = dockerode.getContainer(containerId)
|
||||||
container.remove({ force: shouldForce === true }, function (error) {
|
container.remove({ force: shouldForce === true }, function (error) {
|
||||||
|
@ -614,9 +590,6 @@ module.exports = DockerRunner = {
|
||||||
Settings.clsi.docker.maxContainerAge || (oneHour = 60 * 60 * 1000),
|
Settings.clsi.docker.maxContainerAge || (oneHour = 60 * 60 * 1000),
|
||||||
|
|
||||||
examineOldContainer(container, callback) {
|
examineOldContainer(container, callback) {
|
||||||
if (callback == null) {
|
|
||||||
callback = function (error, name, id, ttl) {}
|
|
||||||
}
|
|
||||||
const name =
|
const name =
|
||||||
container.Name ||
|
container.Name ||
|
||||||
(container.Names != null ? container.Names[0] : undefined)
|
(container.Names != null ? container.Names[0] : undefined)
|
||||||
|
@ -633,9 +606,6 @@ module.exports = DockerRunner = {
|
||||||
},
|
},
|
||||||
|
|
||||||
destroyOldContainers(callback) {
|
destroyOldContainers(callback) {
|
||||||
if (callback == null) {
|
|
||||||
callback = function (error) {}
|
|
||||||
}
|
|
||||||
dockerode.listContainers({ all: true }, function (error, containers) {
|
dockerode.listContainers({ all: true }, function (error, containers) {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
return callback(error)
|
return callback(error)
|
||||||
|
@ -677,7 +647,12 @@ module.exports = DockerRunner = {
|
||||||
const randomDelay = Math.floor(Math.random() * 5 * 60 * 1000)
|
const randomDelay = Math.floor(Math.random() * 5 * 60 * 1000)
|
||||||
containerMonitorTimeout = setTimeout(() => {
|
containerMonitorTimeout = setTimeout(() => {
|
||||||
containerMonitorInterval = setInterval(
|
containerMonitorInterval = setInterval(
|
||||||
() => DockerRunner.destroyOldContainers(),
|
() =>
|
||||||
|
DockerRunner.destroyOldContainers((err) => {
|
||||||
|
if (err) {
|
||||||
|
logger.error({ err }, 'failed to destroy old containers')
|
||||||
|
}
|
||||||
|
}),
|
||||||
(oneHour = 60 * 60 * 1000)
|
(oneHour = 60 * 60 * 1000)
|
||||||
)
|
)
|
||||||
}, randomDelay)
|
}, randomDelay)
|
||||||
|
|
Loading…
Reference in a new issue