npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

redis-server

v1.2.2

Published

Start and stop a Redis server.

Downloads

32,316

Readme

redis-server

NPM version Build Status Coverage Status License

Start and stop a local Redis server in Node.js like a boss.

Installation


npm install redis-server

Usage

The constructor exported by this module optionally accepts a single argument; a number or string that is a port or an object for configuration.

Basic Example


const RedisServer = require('redis-server');

// Simply pass the port that you want a Redis server to listen on.
const server = new RedisServer(6379);

server.open((err) => {
  if (err === null) {
    // You may now connect a client to the Redis
    // server bound to port 6379.
  }
});

Configuration

| Property | Type | Default | Description |:---------|:-------|:-------------|:----------- | bin | String | redis-server | A Redis server binary path. | conf | String | | A Redis server configuration file path. | port | Number | 6379 | A port to bind a Redis server to. | slaveof | String | | An address of a Redis server to sync with.

A Redis server binary must be available. If you do not have one in $PATH, provide a path in configuration.


const server = new RedisServer({
  port: 6379,
  bin: '/opt/local/bin/redis-server'
});

You may use a Redis configuration file instead of configuration object properties that are flags (i.e. port and slaveof). If conf is provided, no flags will be passed to the binary.


const server = new RedisServer({
  conf: '/path/to/redis.conf'
});

Methods

For methods that accept callback, callback will receive an Error as the first argument if a problem is detected; null, if not.

RedisServer#open()

Attempt to open a Redis server. Returns a Promise.

Promise style open()

server.open().then(() => {
  // You may now connect a client to the Redis server bound to `server.port`.
});
Callback style open()

server.open((err) => {
  if (err === null) {
    // You may now connect a client to the Redis server bound to `server.port`.
  }
});

RedisServer#close()

Close the associated Redis server. Returns a Promise. NOTE: Disconnect clients prior to calling this method to avoid receiving connection errors from clients.

Promise style close()

server.close().then(() => {
  // The associated Redis server is now closed.
});
Callback style close()

server.close((err) => {
  // The associated Redis server is now closed.
});

Properties

RedisServer#isOpening

Determine if the instance is starting a Redis server; true while a process is spawning, and/or about to be spawned, until the contained Redis server either starts or errs.

RedisServer#isRunning

Determine if the instance is running a Redis server; true once a process has spawned and the contained Redis server is ready to service requests.

RedisServer#isClosing

Determine if the instance is closing a Redis server; true while a process is being, or about to be, killed until the contained Redis server either closes or errs.

Events

stdout

Emitted when a Redis server prints to stdout.

opening

Emitted when attempting to start a Redis server.

open

Emitted when a Redis server becomes ready to service requests.

closing

Emitted when attempting to stop a Redis server.

close

Emitted once a Redis server has stopped.