From 345485f0ed4e313e158d90d21c70e193c936e91d Mon Sep 17 00:00:00 2001 From: Yutsuo Date: Mon, 26 Nov 2018 13:07:46 -0200 Subject: [PATCH] phase II done - now cleanup, review and upgrade --- README.md | 11 ++++++----- docker-compose.yml | 2 +- nginx/nginx.conf | 2 +- node/README.md | 9 +++++++++ node/app.js | 10 +++++++++- node/package.json | 4 +++- prometheus.yml | 8 +++++++- 7 files changed, 36 insertions(+), 10 deletions(-) create mode 100755 node/README.md diff --git a/README.md b/README.md index 669081d..e075d3d 100755 --- a/README.md +++ b/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! +>_> diff --git a/docker-compose.yml b/docker-compose.yml index 6f98e3f..5fc1fe9 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,7 @@ services: build: ./nginx image: custom/nginx ports: - - 8080:8080 + - 8000:8000 networks: - network_1 app: diff --git a/nginx/nginx.conf b/nginx/nginx.conf index 49ffa91..293861a 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -11,7 +11,7 @@ http { } server { - listen 8080; + listen 8000; location / { proxy_pass http://app; diff --git a/node/README.md b/node/README.md new file mode 100755 index 0000000..e075d3d --- /dev/null +++ b/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? + +>_> + diff --git a/node/app.js b/node/app.js index 43c1471..0441d61 100755 --- a/node/app.js +++ b/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); diff --git a/node/package.json b/node/package.json index 91b91ae..176f7d9 100755 --- a/node/package.json +++ b/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" } } diff --git a/prometheus.yml b/prometheus.yml index 170cc81..7aa2d9f 100755 --- a/prometheus.yml +++ b/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 \ No newline at end of file