Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Simple example of scalable nodejs websocket server

NotificationsYou must be signed in to change notification settings

animir/scalable-nodejs-socketio-redis-nginx-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Shows a list of IP addresses viewing the pageApplication launched with docker: node server with redis server as a message broker for scalingand nginx server as a balancer and web server for static client files (index.html andindex.js)

Installation

  1. git clone this repo
  2. Make sure you use latestdocker anddocker-compose
  3. Runyarn build fromclient directory to createdist/index.js bundle
  4. Rundocker-compose up. It buildsweb,redis andsocket-server containers for you.Rundocker-compose build if you want to rebuild containers
  5. Site available on0.0.0.0:80 on Unix-like systems (checkifconfig to find correct IP if not)

Development

Client uses Webpack to create bundledist/index.js.If something changed inclient/src directory,yarn build should be launched to update index.js bundle

Automated Test

  1. Unit tests launchyarn test-unit
  2. Functional tests must be launched in docker env likedocker exec currentlyviewingapp_socket-server_1 yarn test-func

Manual Test

!!!NOTE!!! In purpose of testing on one machine, websocket server doesn't use real IPs, but number which changed every 10 seconds.

When user opens a tab in browser, number N assigned to this tab via socket connection.

When user opens the second tab in browser, application assigns the same number N or the new number M.

IF the second tab assigned with number N and user closes the first tab, it's "IP-number" still in the list,because there is at least one tab.It allows to see how would it work if user opens many tabs from the same and different computers.

Uncomment server/src/index.js:15 if you wish to see real IP addresses (requires to restart docker container)

TODOs

  1. add deploy script to launchyarn build before docker containers start.Ignore client index.js bundle from get repo

About

Simple example of scalable nodejs websocket server

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp