Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Cloud_Computing
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alexander Tim Hobelsberger
Cloud_Computing
Commits
3c933d31
You need to sign in or sign up before continuing.
Commit
3c933d31
authored
Dec 14, 2022
by
Alexander Tim Hobelsberger
Browse files
Options
Downloads
Patches
Plain Diff
nginxConfig
parent
0b8fed38
No related branches found
No related tags found
1 merge request
!10
Skalierbarkeit
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
docker-compose.yaml
+10
-8
10 additions, 8 deletions
docker-compose.yaml
index.js
+3
-4
3 additions, 4 deletions
index.js
nginx/nginx.conf
+6
-6
6 additions, 6 deletions
nginx/nginx.conf
with
19 additions
and
18 deletions
docker-compose.yaml
+
10
−
8
View file @
3c933d31
...
@@ -11,46 +11,48 @@ services:
...
@@ -11,46 +11,48 @@ services:
-
server-ringo
-
server-ringo
ports
:
ports
:
-
"
3600:80"
-
"
3600:80"
logging
:
driver
:
none
server-john
:
server-john
:
build
:
./
build
:
./
links
:
links
:
-
redis
-
redis
expose
:
expose
:
-
"
360
0
"
-
"
360
1
"
environment
:
environment
:
-
NAME=john
-
NAME=john
-
PORT=360
0
-
PORT=360
1
server-paul
:
server-paul
:
build
:
./
build
:
./
links
:
links
:
-
redis
-
redis
expose
:
expose
:
-
"
360
0
"
-
"
360
2
"
environment
:
environment
:
-
NAME=paul
-
NAME=paul
-
PORT=360
0
-
PORT=360
2
server-george
:
server-george
:
build
:
./
build
:
./
links
:
links
:
-
redis
-
redis
expose
:
expose
:
-
"
360
0
"
-
"
360
3
"
environment
:
environment
:
-
NAME=george
-
NAME=george
-
PORT=360
0
-
PORT=360
3
server-ringo
:
server-ringo
:
build
:
./
build
:
./
links
:
links
:
-
redis
-
redis
expose
:
expose
:
-
"
360
0
"
-
"
360
4
"
environment
:
environment
:
-
NAME=ringo
-
NAME=ringo
-
PORT=360
0
-
PORT=360
4
redis
:
redis
:
image
:
redis
image
:
redis
...
...
This diff is collapsed.
Click to expand it.
index.js
+
3
−
4
View file @
3c933d31
...
@@ -26,11 +26,11 @@ const { resolve } = require('path');
...
@@ -26,11 +26,11 @@ const { resolve } = require('path');
const
User
=
require
(
'
./models/user
'
);
const
User
=
require
(
'
./models/user
'
);
var
port
=
process
.
env
.
PORT
||
3000
;
var
port
=
process
.
env
.
PORT
||
3000
;
const
redis
=
require
(
'
socket.io-redis
'
);
const
redis
=
require
(
'
socket.io-redis
'
);
const
{
createAdapter
}
=
require
(
'
@socket.io/redis-adapter
'
);
//Redis Adapter so every packet is sent to all matching clients connected to the current Server
//Redis Adapter so every packet is sent to all matching clients connected to the current Server
io
.
adapter
(
redis
({
host
:
'
redis
'
,
port
:
6379
}));
io
.
adapter
(
redis
({
host
:
'
redis
'
,
port
:
6379
}));
//DB Connection
//DB Connection
//mongoose.connect("mongodb://mongodb:27017/cloudComputing");
//mongoose.connect("mongodb://mongodb:27017/cloudComputing");
...
@@ -190,6 +190,7 @@ app.get('/login', (req, res) => {
...
@@ -190,6 +190,7 @@ app.get('/login', (req, res) => {
io
.
on
(
'
connection
'
,
(
socket
)
=>
{
io
.
on
(
'
connection
'
,
(
socket
)
=>
{
socket
.
on
(
'
userLogin
'
,
async
function
(
response
)
{
socket
.
on
(
'
userLogin
'
,
async
function
(
response
)
{
console
.
log
(
"
userLogin event on:
"
+
port
);
await
addUserToActiveUsers
(
response
,
socket
);
await
addUserToActiveUsers
(
response
,
socket
);
clientActiveUsers
.
set
(
activeUsers
.
size
);
clientActiveUsers
.
set
(
activeUsers
.
size
);
});
});
...
@@ -223,7 +224,7 @@ async function addUserToActiveUsers(response, socket) {
...
@@ -223,7 +224,7 @@ async function addUserToActiveUsers(response, socket) {
clientActiveUsers
.
set
(
activeUsers
.
size
);
clientActiveUsers
.
set
(
activeUsers
.
size
);
var
userArr
=
Array
.
from
(
activeUsers
.
values
());
var
userArr
=
Array
.
from
(
activeUsers
.
values
());
console
.
log
(
userArr
);
//
console.log(userArr);
io
.
emit
(
'
updateUserlist
'
,
{
io
.
emit
(
'
updateUserlist
'
,
{
userList
:
userArr
userList
:
userArr
});
});
...
@@ -487,8 +488,6 @@ function serverListen() {
...
@@ -487,8 +488,6 @@ function serverListen() {
server
.
listen
(
process
.
env
.
PORT
,
function
()
{
server
.
listen
(
process
.
env
.
PORT
,
function
()
{
console
.
log
(
'
Server listening at port %d
'
,
port
);
console
.
log
(
'
Server listening at port %d
'
,
port
);
console
.
log
(
'
Server listening at port
'
,
process
.
env
.
PORT
);
console
.
log
(
'
Hello, I
\'
m
'
,
process
.
env
.
NAME
,
'
how can I help?
'
);
console
.
log
(
'
Hello, I
\'
m
'
,
process
.
env
.
NAME
,
'
how can I help?
'
);
});
});
...
...
This diff is collapsed.
Click to expand it.
nginx/nginx.conf
+
6
−
6
View file @
3c933d31
...
@@ -26,15 +26,15 @@ http {
...
@@ -26,15 +26,15 @@ http {
upstream
nodes
{
upstream
nodes
{
# enable sticky session with either "hash" (uses the complete IP address)
# enable sticky session with either "hash" (uses the complete IP address)
#hash $remote_addr consistent;
#hash $remote_addr consistent;
least_conn
;
#
least_conn;
# or "ip_hash" (uses the first three octets of the client IPv4 address, or the entire IPv6 address)
# or "ip_hash" (uses the first three octets of the client IPv4 address, or the entire IPv6 address)
#
ip_hash;
ip_hash
;
# or "sticky" (needs commercial subscription)
# or "sticky" (needs commercial subscription)
# sticky cookie srv_id expires=1h domain=.example.com path=/;
# sticky cookie srv_id expires=1h domain=.example.com path=/;
server
server-john
:
360
0
;
server
server-john
:
360
1
;
server
server-paul
:
360
0
;
server
server-paul
:
360
2
;
server
server-george
:
360
0
;
server
server-george
:
360
3
;
server
server-ringo
:
360
0
;
server
server-ringo
:
360
4
;
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment