lib/sync-server.js
function stopAll(cb) {
  //sync is not started yet, but connect could be called already. In this case, just reset a few things
  if (!syncStarted) {
    interceptors.restore();
    dataHandlers.restore();
    hashProvider.restore();
    mongoDbClient = null;
    redisClient = null;
    metricsClient = null;
    return cb();
  }
  debug('stopAll syncs');
  datasetClientCleaner.stop();
  async.parallel([
    async.apply(syncStorage.updateManyDatasetClients, {}, {stopped: true}),
    async.apply(stopAllWorkers, syncWorkers),
    async.apply(stopAllWorkers, ackWorkers),
    async.apply(stopAllWorkers, pendingWorkers),
    async.apply(syncScheduler.stop.bind(syncScheduler))
  ], function(err) {
    if (err) {
      debugError('Failed to stop sync due to error : %s', err);
      return cb(err);
    }
    setConfig();
    interceptors.restore();
    dataHandlers.restore();
    hashProvider.restore();
    mongoDbClient = null;
    redisClient = null;
    metricsClient = null;
    ackQueue = null;
    pendingQueue = null;
    syncQueue = null;
    ackWorkers = [];
    pendingWorkers = [];
    syncWorkers = [];
    syncStarted = false;
    syncLock = null;
    datasetClientCleaner = null;
    // Reset the memoized start fn so it can be called again
    module.exports.api.start = async.memoize(start);
    return cb();
  });
}
function stopAll(cb) {
  //sync is not started yet, but connect could be called already. In this case, just reset a few things
  if (!syncStarted) {
    interceptors.restore();
    dataHandlers.restore();
    hashProvider.restore();
    mongoDbClient = null;
    redisClient = null;
    metricsClient = null;
    return cb();
  }
  debug('stopAll syncs');
  datasetClientCleaner.stop();
  async.parallel([
    async.apply(syncStorage.updateManyDatasetClients, {}, {stopped: true}),
    async.apply(stopAllWorkers, syncWorkers),
    async.apply(stopAllWorkers, ackWorkers),
    async.apply(stopAllWorkers, pendingWorkers),
    async.apply(syncScheduler.stop.bind(syncScheduler))
  ], function(err) {
    if (err) {
      debugError('Failed to stop sync due to error : %s', err);
      return cb(err);
    }
    setConfig();
    interceptors.restore();
    dataHandlers.restore();
    hashProvider.restore();
    mongoDbClient = null;
    redisClient = null;
    metricsClient = null;
    ackQueue = null;
    pendingQueue = null;
    syncQueue = null;
    ackWorkers = [];
    pendingWorkers = [];
    syncWorkers = [];
    syncStarted = false;
    syncLock = null;
    datasetClientCleaner = null;
    // Reset the memoized start fn so it can be called again
    module.exports.api.start = async.memoize(start);
    return cb();
  });
}
Stop cloud data sync service for ALL datasets and reset.
This should really only used by tests.