Browse Source

phase II done - now cleanup, review and upgrade

master
Yutsuo 7 years ago
parent
commit
345485f0ed
  1. 11
      README.md
  2. 2
      docker-compose.yml
  3. 2
      nginx/nginx.conf
  4. 9
      node/README.md
  5. 10
      node/app.js
  6. 4
      node/package.json
  7. 8
      prometheus.yml

11
README.md

@ -1,8 +1,9 @@
Quinta tarefa:
LABBS ONBOARD PHASE 2 COMPLETED!
* Configure um Nginx para ser o proxy reverso do seu NodeJS.
* Segmente as redes do Nginx e do MongoDB.
* Crie duas redes: [Nginx] —--rede1–-- [NodeJS] —--rede2–-- [MongoDB].
NOW MOVING ON TO GLOBAL DOMINATION AND...
...
...UH?
WHADDYA MEAN I KNOW NOTHING YET?
> Mande uma foto do docker-compose, “docker network ls” e do App rodando!
>_>

2
docker-compose.yml

@ -6,7 +6,7 @@ services:
build: ./nginx
image: custom/nginx
ports:
- 8080:8080
- 8000:8000
networks:
- network_1
app:

2
nginx/nginx.conf

@ -11,7 +11,7 @@ http {
}
server {
listen 8080;
listen 8000;
location / {
proxy_pass http://app;

9
node/README.md

@ -0,0 +1,9 @@
LABBS ONBOARD PHASE 2 COMPLETED!
NOW MOVING ON TO GLOBAL DOMINATION AND...
...
...UH?
WHADDYA MEAN I KNOW NOTHING YET?
>_>

10
node/app.js

@ -5,7 +5,9 @@ const Schema = mongoose.Schema;
const database = 'mongodb://' + process.env.mongousr + ':' + process.env.mongopwd + '@mongo:27017/test';
const today = new Date();
var counter = 0;
const Prometheus = require("prom-client");
const Prometheus = require('prom-client');
var fs = require('file-system');
var marked = require('marked');
// database connection (with retries)
const options = {
@ -86,6 +88,12 @@ app.get('/', (req, res)=>{
libCounter.inc(); // for prometheus lib_invocation_count metric
});
app.get('/test', function(req, res) {
var path = '/app/README.md';
var file = fs.readFileSync(path, 'utf8');
res.send(marked(file.toString()));
});
app.get('/info', function(req, res){
colors.find({}).then(function (colors) {
res.json(colors);

4
node/package.json

@ -16,6 +16,8 @@
"dependencies": {
"express": "^4.16.3",
"mongoose": "^5.3.2",
"prom-client": "^11.2.0"
"prom-client": "^11.2.0",
"file-system": "^2.2.2",
"marked": "^0.5.2"
}
}

8
prometheus.yml

@ -2,8 +2,14 @@ global:
scrape_interval: 1s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 5s # Evaluate rules every 15 seconds. The default is every 1 minute.
scrape_configs:
- job_name: 'app1-01' # Job name
static_configs:
- targets: ['app:3001'] # mysqld_exporter address and port
labels:
alias: 'app1-02' # alias name given to this instance
- job_name: 'app1' # Job name
metrics_path: /metrics2
static_configs:
- targets: ['app:3001'] # mysqld_exporter address and port
labels:
alias: 'app1' # alias name given to this instance
alias: 'app1' # alias name given to this instance
Loading…
Cancel
Save