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

podkeeper

v0.3.0

Published

> ⚠️ **Warning:** PodKeeper is currently in pre-1.0.0 release. Expect potential changes and experimental features that may not be fully stable yet.

Downloads

83

Readme

PodKeeper

⚠️ Warning: PodKeeper is currently in pre-1.0.0 release. Expect potential changes and experimental features that may not be fully stable yet.

PodKeeper is a node.js open-source library for starting and stopping Docker containers in a way that ensures they won’t linger if the host program crashes or exits unexpectedly without properly stopping them.

PodKeeper is written in TypeScript and comes bundled with TypeScript types.

Getting Started

  1. Install podkeeper:

    npm i --save-dev podkeeper
  2. Pull container you wish to launch beforehand:

    docker pull postgres:latest
  3. Start / stop container programmatically:

    import { Postgres } from 'podkeeper';
    
    const postgres = await Postgres.start();
    // do something with container...
    await postgres.stop();

Bundled services & API

PodKeeper comes bundled with the following pre-configured services:

  • MySQL:

    import { MySQL } from 'podkeeper';
  • Postgres

    import { Postgres } from 'podkeeper';
  • Minio

    import { Minio } from 'podkeeper';

If a popular service is missing, please do not hesitate to submit a pull request. Alternatively, you can launch a generic container service with the GenericService class:

import { GenericService } from 'podkeeper';

cosnt service = await GenericService.start({
  imageName: string,
  ports: number[],
  healthcheck?: {
    test: string[],
    intervalMs: number,
    retries: number,
    startPeriodMs: number,
    timeoutMs: number,
  },
  command?: string[],
  env?: { [key: string]: string | number | boolean | undefined };
});

How It Works

Each Docker container has a primary process, known as the "entrypoint," which keeps the container running. For example, when you start a PostgreSQL container, it runs the postgres binary. When this binary exits, the container stops as well.

PodKeeper wraps the entrypoint in a special binary called deadmanswitch, which not only starts the entrypoint but also launches a WebSocket server. The client that initiated the container must connect to this WebSocket server; otherwise, the container will self-terminate after 10 seconds.

This setup creates a connection between the launched container and its owner. Whenever this WebSocket disconnects, the deadmanswitch program automatically stops the container.

PodKeeper vs. TestContainers

Both PodKeeper and TestContainers provide solutions for starting, stopping, and cleaning up Docker containers:

  • TestContainers uses a dedicated Docker container called "Ryuk" to manage cleanup.
  • PodKeeper relies on a dead man's switch mechanism for cleanup.

While TestContainers is a mature, industry-proven tool, PodKeeper is an experimental alternative that explores a different approach.

There are also some notable differences in API design philosophy:

  • Process Behavior: PodKeeper services prevent the Node.js process from exiting, while TestContainers services do not.
  • Container Pulling: PodKeeper does not implicitly pull containers, requiring them to be available beforehand, whereas TestContainers lazily pulls containers as needed when launching a service.
  • Healthchecks: The services that PodKeeper ships out-of-the-box are pre-configured to use proper healthchecks.