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

greenlock-cluster-app

v1.1.3

Published

a tool for managing multiple node servers on one domain

Downloads

4

Readme

greenlock-cluster-app

Greenlock-cluster-app is a tool for managing multiple node servers on one domain. The cluster uses greenlock-express to generate a SSL certificate, that is provided to each pod through ENV. Pods are accessible through their specified port.

Point a dynamic dns to your address. Install and start the app with your credentials and you can start hosting your secure servers.

The cluster starts pods with the 'start' script specified in the pod's package.json. The pods have access to a few ENV variables; The SSL certificate's process.env.CERT and process.env.PRIVKEY, process.env.PORT to be used as the server port, and the process.env.REPORT hook, which is very important. It send a signal back to the cluster with the process id. When the pod is stopped the cluster can kill the process.

After a restart of the cluster, pods that were previously online will automatically start up. When a pod crashes it will automatically be detected and stopped. The pod's status will be set to crashed. It will only restart manually.

First time; It can take a few minutes for the ssl certificates to appear.

Installation

mkdir greenlock-cluster

cd greenlock-cluster

npm init -y

npm i git+https://github.com/EthanHermsey/greenlock-cluster-app.git

npx greenlock-cluster-app

Setup

Fill in email, domain and homepage.

The email and domain will be used to get a ssl certificate and the homepage will be use for redirection when someone navigates to the domain.

Add pod

During setup a directory /pods will be created. You can add your node project folder here, it will automatically show up in the cluster. You can type 'list' to see all the pods.

Set pod

Use the set command to set up a pod to specify the port it will use and if the pod should auto-restart.

Up pod

Use the up command to start the pod.

Pod example

In the pod you will have access to:

  • process.env.PORT
  • process.env.PRIVKEY
  • process.env.CERT
  • process.env.REPORT

You have to add eval( process.env.REPORT )() to run the report hook. This is used to kill the process when the pod is stopped. When you forget to do this you will have to manually kill the process in a taskmanager.

It also works with websocket and socket.io. The packages need to be installed first.

"use strict";
const https = require( 'https' );
const express = require( 'express' );

//GREENLOCK CLUSTER PID HOOK
eval( process.env.REPORT )();

const app = express();
app.use( "/", function ( req, res ) {

	res.setHeader( "Content-Type", "text/html; charset=utf-8" );
	res.end( "Hello, World!\n\n💚 🔒.js" );

} );

const server = https.createServer(
	{
		key: process.env.PRIVKEY,
		cert: process.env.CERT
	},
	app
).listen( process.env.PORT || 3000, () => {

		console.log( `TestServer: Listening on port: ${process.env.PORT || 3000}` );

} );

new ws.Server( { server: server, path: '/' } );

Commands

  • list

    List all available pods and see their status

  • set [ name ] [ port ] [ auto-restart ]

    Set pod settings. [ name ] as string, [ port ] as number, [ auto-restart ] as true/false

  • up [ name ]

    Start pod with name. You can use 'all' to select all pods

  • down [ name ]

    Stop pod with name. You can use 'all' to select all pods

  • log [ name ]

    Show logs for pod with name. You can use 'all' to select all pods

  • help

    Shows the help menu.

  • quit

    Exit cluster.