Fix service status
This commit is contained in:
@@ -73,19 +73,16 @@ function removePrivateFields(registryConfig) {
|
||||
return registryConfig;
|
||||
}
|
||||
|
||||
function ping(callback) {
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
async function ping() {
|
||||
// do not let the request linger
|
||||
const connection = new Docker({ socketPath: DOCKER_SOCKET_PATH, timeout: 1000 });
|
||||
|
||||
connection.ping(function (error, result) {
|
||||
if (error) return callback(new BoxError(BoxError.DOCKER_ERROR, error));
|
||||
if (Buffer.isBuffer(result) && result.toString('utf8') === 'OK') return callback(null); // sometimes it returns buffer
|
||||
if (result === 'OK') return callback(null);
|
||||
const [error, result] = await safe(connection.ping());
|
||||
if (error) throw new BoxError(BoxError.DOCKER_ERROR, error);
|
||||
if (Buffer.isBuffer(result) && result.toString('utf8') === 'OK') return; // sometimes it returns buffer
|
||||
if (result === 'OK') return;
|
||||
|
||||
callback(new BoxError(BoxError.DOCKER_ERROR, 'Unable to ping the docker daemon'));
|
||||
});
|
||||
throw new BoxError(BoxError.DOCKER_ERROR, 'Unable to ping the docker daemon');
|
||||
}
|
||||
|
||||
async function getRegistryConfig(image) {
|
||||
|
||||
Reference in New Issue
Block a user