This repository contains two Node.js services that demonstrate a simple session-management workflow:
myapp/: hosts a singleMyAppprocess that exposes/and/pingendpoints and spins up a lightweight worker loop. It reads runtime parameters (session-id,port) from the command line, so multiple instances can run side-by-side.session-manager/: contains aSessionManagerthat talks to the Docker daemon, starts newmyappcontainers, and exposes an HTTP control plane. The accompanyingSessionManagerAppexposes proxy endpoints (/session/:id,/session/:id/ping) plus/sessions,/create,/killfor observing and manipulating sessions.
Ensure Docker and Docker Compose are available on your machine. The repository ships with helper Makefile targets that build and run the services:
-
Install dependencies (this installs separately inside both packages):
make npm-install
-
Build both services and their containers:
make build-image
This compiles each
.tsentry point and producessession-run,myapp-dev, andmanager-devimages. -
Start the manager service (this spins up the manager via Docker Compose, mounting
/var/run/docker.sockso it can control Docker and attaching tosys-networkfor service discovery):make run-manager
After it starts, visit
http://localhost:8080, run any api commands fromsession-manager.rest. CTRL+C tears down the stack. -
Run a standalone MyApp instance (for debugging, without the manager):
make run-app
This runs
myappinside Docker with debugging enabled on port 9230 and binds ports for the app.
- Manager containers join
sys-networkso they can resolve dynamically created sessions such assession-1and talk to them over their exposed ports (e.g., 10011 forsession-1). /session/:idproxy on the manager forwards HTTP calls to the live session container, while/session/:id/pingfetches that session’s/pingendpoint and returns the result back through the manager./createand/killHTTP hooks let you spawn or remove session containers from the manager UI.