Browse Source

wasn't using the database host

Patrick Falls 12 years ago
parent
commit
01f2a6d78c
4 changed files with 9 additions and 9 deletions
  1. 2 2
      express/app.js
  2. 2 2
      express/setup.py
  3. 3 3
      nodejs/hello.js
  4. 2 2
      nodejs/setup.py

+ 2 - 2
express/app.js

@@ -10,7 +10,7 @@ var cluster = require('cluster')
   , async = require('async')
   , conn = mongoose.connect('mongodb://localhost/hello_world')
   , Mapper = require('mapper')
-  , connMap = { user: 'benchmarkdbuser', password: 'benchmarkdbpass', database: 'hello_world' };
+  , connMap = { user: 'benchmarkdbuser', password: 'benchmarkdbpass', database: 'hello_world', host: 'localhost' };
 
 var Schema = mongoose.Schema
   , ObjectId = Schema.ObjectId;
@@ -101,7 +101,7 @@ if (cluster.isMaster) {
 
   app.get('/fortune', function(req, res) {
     Fortune.all(function (err, fortunes) {
-      var newFortune = Fortune.build({message: "Additional fortune added at request time."});
+      var newFortune = {id: 0, message: "Additional fortune added at request time."};
       fortunes.push(newFortune);
       fortunes.sort(sortFortunes);
 

+ 2 - 2
express/setup.py

@@ -6,7 +6,7 @@ import os
 
 def start(args):
   setup_util.replace_text("express/app.js", "mongodb:\/\/.*\/hello_world", "mongodb://" + args.database_host + "/hello_world")
-  setup_util.replace_text("express/app.js", "host: '.*',", "host: '" + args.database_host + "',")
+  setup_util.replace_text("express/app.js", "localhost", args.database_host)
 
   try:
     subprocess.check_call("npm install", shell=True, cwd="express")
@@ -24,4 +24,4 @@ def stop():
         os.kill(pid, 9)
       except OSError:
         pass
-  return 0
+  return 0

+ 3 - 3
nodejs/hello.js

@@ -19,17 +19,17 @@ var http = require('http')
   , async = require('async')
   , libmysql = require('mysql-libmysqlclient').createConnectionSync()
   , mongoose = require('mongoose')
-  , conn = mongoose.connect('mongodb://localhost/hello_world')
+  , conn = mongoose.connect('mongodb://172.16.98.98/hello_world')
   , MongoClient = require('mongodb').MongoClient
   , Mapper = require('mapper')
-  , connMap = { user: 'benchmarkdbuser', password: 'benchmarkdbpass', database: 'hello_world' };
+  , connMap = { user: 'benchmarkdbuser', password: 'benchmarkdbpass', database: 'hello_world', host: 'localhost' };
 
 var collection = null;
 Mapper.connect(connMap, {verbose: false, strict: false});
 var World = Mapper.map("World", "id", "randomNumber")
 
 libmysql.connectSync('localhost', 'benchmarkdbuser', 'benchmarkdbpass', 'hello_world');
-MongoClient.connect('mongodb://localhost/hello_world?maxPoolSize=5', function(err, db) {
+MongoClient.connect('mongodb://172.16.98.98/hello_world?maxPoolSize=5', function(err, db) {
   collection = db.collection('world');
 });
 

+ 2 - 2
nodejs/setup.py

@@ -6,7 +6,7 @@ import os
 
 def start(args):
   setup_util.replace_text("nodejs/hello.js", "mongodb:\/\/.*\/hello_world", "mongodb://" + args.database_host + "/hello_world")
-  setup_util.replace_text("nodejs/hello.js", "host: '.*',", "host: '" + args.database_host + "',")
+  setup_util.replace_text("nodejs/hello.js", "localhost", args.database_host)
 
   try:
     subprocess.check_call("npm install", shell=True, cwd="nodejs")
@@ -24,4 +24,4 @@ def stop():
         os.kill(pid, 9)
       except OSError:
         pass
-  return 0
+  return 0