Commit a77cdbacc4446265fcd24a9510265e6899e69939
1 parent
7f6f9c69
Exists in
master
and in
1 other branch
V. 0.5.2 - Adicionadas mensagens para avisar se ocorreram as conexões com o banco de dados.
Showing
2 changed files
with
13 additions
and
0 deletions
Show diff stats
routes/mapRoutes.js
services/databases.js
| 1 | +// Create global connections with SQLServer (comercial) and Postgres (mapping) | ||
| 2 | +// | ||
| 1 | var ms_sql = require("mssql"); | 3 | var ms_sql = require("mssql"); |
| 2 | var pg = require("pg"); | 4 | var pg = require("pg"); |
| 3 | const keys = require("../config/keys"); | 5 | const keys = require("../config/keys"); |
| @@ -7,8 +9,17 @@ pg.defaults.poolSize = 25; | @@ -7,8 +9,17 @@ pg.defaults.poolSize = 25; | ||
| 7 | 9 | ||
| 8 | // Creates global pool connection with Postgres and MS SqlServer | 10 | // Creates global pool connection with Postgres and MS SqlServer |
| 9 | global.poolPg = new pg.Pool(keys.pg); | 11 | global.poolPg = new pg.Pool(keys.pg); |
| 12 | +global.poolPg.connect(function(err, client, done){ | ||
| 13 | + if(err){ | ||
| 14 | + console.error("Error connectin to Postgres Server"+ err.stack); | ||
| 15 | + } else { | ||
| 16 | + console.log("Connection estabilished with Postgres Server"); | ||
| 17 | + } | ||
| 18 | +}) | ||
| 10 | global.poolMsql = new ms_sql.ConnectionPool(keys.msql, function(err) { | 19 | global.poolMsql = new ms_sql.ConnectionPool(keys.msql, function(err) { |
| 11 | if (err) { | 20 | if (err) { |
| 12 | console.log("Não conectou com SQLServer:\n" + err); | 21 | console.log("Não conectou com SQLServer:\n" + err); |
| 22 | + } else{ | ||
| 23 | + console.log("Connection estabilished with SQLServer"); | ||
| 13 | } | 24 | } |
| 14 | }); | 25 | }); |
| 15 | \ No newline at end of file | 26 | \ No newline at end of file |