Git Product home page Git Product logo

scan's Introduction

scan

Containerized utility to scan Redis keys, using Node.js

Config

See app/config.js

module.exports = {
    development: {
        logging: 'debug',
        pattern: '*',
        format: 'verbose'
    },
    help: {
        info: {
            default: 'verbose',
            options: ['terse', 'verbose'],
            description: 'display configuration defaults'
        },
        redisUrl: {
            default: 'redis://localhost:6379'
        },
        logging: {
            default: 'info'
        },
        pattern: {
            description: 'matching pattern for Redis scan'
        },
        format: {
            default: 'terse',
            options: ['terse', 'verbose']
        }
    }
};

where the default redisUrl is 'redis://localhost:6379'

Implementation

See app/index.js

require('../components/redisCliApp')(require('./config')).then(main);

async function main(context) {
    Object.assign(global, context);
    logger.level = config.logging;
    logger.debug('main', config);
    try {
        let cursor;
        while (cursor !== 0) {
            const [result] = await multiExecAsync(client, multi => {
                multi.scan(cursor || 0, 'match', config.pattern);
            });
            cursor = parseInt(result[0]);
            result[1].forEach(key => {
                console.log(key);
            });
        }
    } catch (err) {
        console.error(err);
    } finally {
        end();
    }
}

async function end() {
    client.quit();
}

Docker

Build and run

docker build -t scan https://github.com/evanx/scan.git

where tagged as image scan

docker run --network=host -e pattern='*' scan | head

where --network-host connects to localhost bridge so that the default redisUrl of redis://localhost:6379 works in that case.

As such, you should inspect the source:

git clone https://github.com/evanx/scan.git
cd scan
cat Dockerfile
FROM node:7.4.0
ADD package.json .
RUN npm install
ADD components components
ADD app app
ENV NODE_ENV production
CMD ["node", "--harmony", "app/index.js"]

Having reviewed the code, you can execute as follows:

cat package.json
npm install
pattern='*' npm start

https://twitter.com/@evanxsummers

scan's People

Contributors

dependabot[bot] avatar evanx avatar strongbyte-es avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.