Skip to content

Commit 26feac2

Browse files
authored
Merge pull request #69 from Lemoncode/feature/monitoring
Feature/monitoring
2 parents f84c2ee + 1c132bb commit 26feac2

File tree

73 files changed

+4352
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+4352
-1
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,6 @@ app/
3131
lab/
3232
private.readme.md
3333
04-cloud/00-aks/03-virtual-kubelet/auth.json
34+
35+
# Vagrant
36+
.vagrant

03-cd/exercises/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
### 1. CI/CD de una Java + Gradle
66

7-
En el directorio raíz de este [código fuente](./jenkins-resources/calcultor), crea un `Jenkinsfile` que contenga un pipeline declarativa con los siguientes stages:
7+
En el directorio raíz de este [código fuente](./jenkins-resources), crea un `Jenkinsfile` que contenga un pipeline declarativa con los siguientes stages:
88

99
* **Checkout** descarga de código desde un repositorio remoto, preferentemente utiliza GitHub.
1010
* **Compile** compilar el código fuente, para ello utilizar `gradlew compileJava`
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
*.md
3+
Dockerfile
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM node:16-alpine
2+
3+
WORKDIR /opt/app
4+
5+
COPY . .
6+
7+
RUN npm ci
8+
9+
CMD ["npm", "start"]
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const getRandom = (start, end) => Math.floor((Math.random() * end) + start);
2+
3+
const randomBatchProcess = () => {
4+
const jobs = getRandom(50, 500);
5+
const failed = getRandom(1, 50);
6+
const processed = jobs - failed;
7+
return { jobs, failed, processed };
8+
};
9+
10+
module.exports.batch = () => {
11+
const intervalId = setInterval(() => {
12+
const { jobs, failed, processed } = randomBatchProcess();
13+
console.log(jobs, failed, processed);
14+
}, 5_000);
15+
16+
return intervalId;
17+
};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = ({
2+
port: +process.env.PORT || 3000,
3+
});
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const express = require('express');
2+
const { port } = require('./config');
3+
const { batch } = require('./batch');
4+
5+
const intervalId = batch();
6+
const app = express();
7+
8+
app.get('/metrics', async (_, res) => {
9+
try {
10+
res.send('Not implemented yet');
11+
} catch (ex) {
12+
res.status(500).end(ex);
13+
}
14+
});
15+
16+
app.post('/stop', (_, res) => {
17+
clearInterval(intervalId);
18+
res.send('batch process stopped');
19+
});
20+
21+
app.listen(port, () => {
22+
console.log(`Listening at ${port}`);
23+
});

0 commit comments

Comments
 (0)