Start conversion to postgresql; got connection to pg database without error linking alertmon-dev contianer to pg container.
This commit is contained in:
		
							parent
							
								
									0c19cf7913
								
							
						
					
					
						commit
						44765a46a4
					
				@ -8,6 +8,7 @@
 | 
			
		||||
    "handlebars-form-helpers": "^0.1.3",
 | 
			
		||||
    "moment-timezone": "^0.4.0",
 | 
			
		||||
    "nodemailer": "^1.3.4",
 | 
			
		||||
    "pg": "^4.4.2",
 | 
			
		||||
    "sqlite3": "^3.0.8"
 | 
			
		||||
  },
 | 
			
		||||
  "scripts": {
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										12
									
								
								server.js
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								server.js
									
									
									
									
									
								
							@ -6,7 +6,6 @@ var alertmonUtils = require('./alertmonUtils.js');
 | 
			
		||||
var fs = require("fs");
 | 
			
		||||
var bodyParser = require("body-parser");
 | 
			
		||||
var app = express();
 | 
			
		||||
var logfile = fs.createWriteStream('./db/log.log', {flags: 'a'});
 | 
			
		||||
 | 
			
		||||
// Setup email
 | 
			
		||||
var transporter = nodemailer.createTransport({
 | 
			
		||||
@ -34,6 +33,15 @@ if(!exists) {
 | 
			
		||||
 | 
			
		||||
var sqlite3 = require("sqlite3").verbose();
 | 
			
		||||
var db = new sqlite3.Database(file);
 | 
			
		||||
var pg = require("pg");
 | 
			
		||||
var conString = "postgres://alertmon:alertmon@db/alertmon";
 | 
			
		||||
 | 
			
		||||
pg.connect(conString, function(err, client, done) {
 | 
			
		||||
    if(err) {
 | 
			
		||||
        return console.error('error fetching client from pool', err);
 | 
			
		||||
    }
 | 
			
		||||
    done();
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
db.serialize(function() {
 | 
			
		||||
    if(!exists) {
 | 
			
		||||
@ -166,8 +174,6 @@ app.post('/core/edit/:id', function(req, res){
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
app.get('/core/:id', function(req, res){
 | 
			
		||||
    //res.sendFile("/usr/src/app/index.html");
 | 
			
		||||
    //fs.createReadStream('./log.log').pipe(res);
 | 
			
		||||
    var d = new Date();
 | 
			
		||||
    var coreId = req.params.id;
 | 
			
		||||
    console.log("GET /core/" + coreId + ", " + JSON.stringify(d, 4));
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user