Skip to content

Commit

Permalink
tweak: get servers from config
Browse files Browse the repository at this point in the history
  • Loading branch information
thutasann committed Dec 7, 2024
1 parent 4ed4325 commit ca6e0f2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 18 deletions.
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ dist
./**/.next

*.yml
*.json
*.next
# /packages/**/build
# /packages/**/dist
Expand Down
6 changes: 2 additions & 4 deletions standalone-apis/node-load-balancing-sample/backend-servers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @ts-check
const http = require('http');
const servers = require('./config.json').servers;

/**
* Create Server
Expand All @@ -17,7 +18,4 @@ const createServer = (host, port) => {
});
};

createServer('localhost', 3001);
createServer('localhost', 3002);
createServer('localhost', 3003);
createServer('localhost', 3004);
servers.forEach((server) => createServer(server.host, server.port));
8 changes: 8 additions & 0 deletions standalone-apis/node-load-balancing-sample/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"servers": [
{ "host": "localhost", "port": 3001 },
{ "host": "localhost", "port": 3002 },
{ "host": "localhost", "port": 3003 },
{ "host": "localhost", "port": 3004 }
]
}
26 changes: 13 additions & 13 deletions standalone-apis/node-load-balancing-sample/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "load-balancing-sample",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "node backend-servers"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"http-proxy": "^1.18.1"
}
"name": "load-balancing-sample",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "node --watch backend-servers"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"http-proxy": "^1.18.1"
}
}

0 comments on commit ca6e0f2

Please sign in to comment.