GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - cdn77/node-socket-daemon

BranchesTags
Open more actions menu

Latest commit

 

History

54 Commits
54 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
docs
docs
 
 
examples
examples
 
 
src
src
 
 
.editorconfig
.editorconfig
 
 
.gitignore
.gitignore
 
 
.oxfmtrc.json
.oxfmtrc.json
 
 
.oxlintrc.json
.oxlintrc.json
 
 
README.md
README.md
 
 
nodesockd.yml
nodesockd.yml
 
 
package.json
package.json
 
 
pnpm-lock.yaml
pnpm-lock.yaml
 
 
pnpm-workspace.yaml
pnpm-workspace.yaml
 
 
tsconfig.json
tsconfig.json
 
 
tsdown.config.ts
tsdown.config.ts
 
 

Repository files navigation

Nodesockd

This tool is the missing link between a Nginx reverse proxy and a Node.js backend service. Typically, setups like this bind the backend service to a port on the loopback interface, which is secure enough, but adds some overhead. There are some pitfalls to switching over to UNIX sockets though, and this package aims to address them in one fell swoop:

  • atomic deploy, even with database migrations
  • multiple workers supported
  • standby workers for fast failover

Installation

npm install --save nodesockd

Documentation

Quick start

Create a file called nodesockd.yaml in your application's root directory with the following contents:

# nodesockd.yaml
script: build/app.js # the entrypoint of your app
tmpDir: tmp # make sure this directory exists!

Next, in your app entrypoint, you'll need to do something like this:

// src/app.ts

import { nodesockd } from 'nodesockd';
import * as express from 'express';

const app = express();

// register routes etc.

const server = app.listen(nodesockd.socketPath ?? 1234, async () => {
  // tell Nodesockd that the worker is ready to start serving requests:
  await nodesockd.reportOnline();
});

nodesockd.on('shutdown', () => {
  // when Nodesockd tells the worker to shut down:
  server.close();
});

Now you can run your app like this:

# through Nodesockd - will listen on port 8000:
node_modules/.bin/nodesockd daemon --dev-server

# change the dev server listen port:
node_modules/.bin/nodesockd daemon --dev-server=8123

# without Nodesockd - will listen on the fallback port 1234
# defined in the app code:
node build/app.js

Of course, this is what you might use for local development; in production, you'll need to set some things up to correctly expose the application sockets to Nginx. Refer to the documentation for more details.

About

No description, website, or topics provided.

Resources

Readme
Activity
Custom properties

Stars

7 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.