Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
masterarbeit-server
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Robin Leber
masterarbeit-server
Commits
ded8d853
Commit
ded8d853
authored
1 year ago
by
Robin Leber
Browse files
Options
Downloads
Patches
Plain Diff
Scale out error handling
parent
a139c55f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/functions/errors.js
+10
-0
10 additions, 0 deletions
src/functions/errors.js
src/functions/helperFunctions.js
+6
-0
6 additions, 0 deletions
src/functions/helperFunctions.js
src/routes/deployRouter.js
+5
-1
5 additions, 1 deletion
src/routes/deployRouter.js
with
21 additions
and
1 deletion
src/functions/errors.js
0 → 100644
+
10
−
0
View file @
ded8d853
class
CustomError
extends
Error
{
constructor
(
message
,
statusCode
)
{
super
(
message
);
this
.
name
=
"
CustomError
"
;
this
.
statusCode
=
statusCode
;
Error
.
captureStackTrace
(
this
,
this
.
constructor
);
}
}
module
.
exports
=
CustomError
;
This diff is collapsed.
Click to expand it.
src/functions/helperFunctions.js
+
6
−
0
View file @
ded8d853
...
@@ -10,6 +10,7 @@ const {
...
@@ -10,6 +10,7 @@ const {
killDockerContainer
,
killDockerContainer
,
}
=
require
(
"
../docker/dockerManager
"
);
}
=
require
(
"
../docker/dockerManager
"
);
const
{
v4
:
uuidv4
}
=
require
(
"
uuid
"
);
const
{
v4
:
uuidv4
}
=
require
(
"
uuid
"
);
const
CustomError
=
require
(
"
./errors.js
"
);
const
fillDockerJS
=
async
(
code
)
=>
{
const
fillDockerJS
=
async
(
code
)
=>
{
const
filePath
=
path
.
resolve
(
__dirname
,
"
../../docker.js
"
);
const
filePath
=
path
.
resolve
(
__dirname
,
"
../../docker.js
"
);
...
@@ -204,6 +205,11 @@ const scaleOut = async (id) => {
...
@@ -204,6 +205,11 @@ const scaleOut = async (id) => {
);
);
const
customCodes
=
await
getCustomCodes
();
const
customCodes
=
await
getCustomCodes
();
const
codeToScale
=
customCodes
.
find
((
code
)
=>
code
.
id
===
id
);
const
codeToScale
=
customCodes
.
find
((
code
)
=>
code
.
id
===
id
);
if
(
!
codeToScale
)
{
throw
new
CustomError
(
"
Need to code first!
"
,
500
);
}
else
if
(
!
codeToScale
.
isDeployed
)
{
throw
new
CustomError
(
"
Need to deploy first!
"
,
500
);
}
const
scaledCode
=
JSON
.
parse
(
JSON
.
stringify
(
codeToScale
));
const
scaledCode
=
JSON
.
parse
(
JSON
.
stringify
(
codeToScale
));
scaledCode
.
isScaled
=
id
;
scaledCode
.
isScaled
=
id
;
scaledCode
.
id
=
uuidv4
();
scaledCode
.
id
=
uuidv4
();
...
...
This diff is collapsed.
Click to expand it.
src/routes/deployRouter.js
+
5
−
1
View file @
ded8d853
...
@@ -57,7 +57,11 @@ deployRouter.post("/scaleOut", async (req, res) => {
...
@@ -57,7 +57,11 @@ deployRouter.post("/scaleOut", async (req, res) => {
res
.
status
(
200
).
json
({
message
:
"
Scale Out erfolgreich
"
});
res
.
status
(
200
).
json
({
message
:
"
Scale Out erfolgreich
"
});
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
error
(
e
);
console
.
error
(
e
);
res
.
status
(
500
).
json
({
message
:
"
Scale Out fehlgeschlagen
"
});
if
(
e
.
name
===
"
CustomError
"
)
{
res
.
status
(
500
).
json
({
message
:
e
.
message
});
}
else
{
res
.
status
(
500
).
json
({
message
:
"
Scale Out fehlgeschlagen
"
});
}
}
}
});
});
...
...
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
register
or
sign in
to comment