Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

MongoDB Error in Todo_App_Mongo example #134

Closed
meshachjackson opened this Issue May 3, 2012 · 10 comments

Comments

Projects
None yet
2 participants
Contributor

meshachjackson commented May 3, 2012

I've been trying to get the example todo app to work with mongo. I've been through the docs, tutorials, and searched for similar bugs, and I just can't seem to find an answer here. I've run npm install -l on 'mongodb', 'metrics', and 'mongodb-wrapper', and still, when I run 'geddy', I get the following:

meshach:/js/gtest$ geddy
[Thu, 03 May 2012 14:56:37 GMT] INFO Server starting with config: {
  "environment": "development",
  "workers": 1,
  "port": 4000,
  "debug": true,
  "rotateWorkers": false,
  "rotationWindow": 7200000,
  "rotationTimeout": 300000,
  "logDir": "/js/gtest/log",
  "gracefulShutdownTimeout": 30000,
  "heartbeatInterval": 5000,
  "heartbeatWindow": 20000,
  "staticFilePath": "/js/gtest/public",
  "sessions": {
    "server": {
      "host": "localhost",
      "port": 27017,
      "db": "testDB",
      "collection": "sessions"
    },
    "store": "mongodb",
    "key": "sid",
    "expiry": 1209600
  },
  "cookieSessionKey": "sdata",
  "metrics": {
    "port": 4001
  },
  "i18n": {
    "defaultLocale": "en-us",
    "loadPaths": [
      "/js/gtest/config/locales"
    ]
  },
  "ssl": null,
  "model": {
    "useTimestamps": false,
    "forceCamel": true
  },
  "detailedErrors": true,
  "hostname": null,
  "db": {
    "mongo": {
      "db": "todo"
    }
  }
}
[Thu, 03 May 2012 14:56:37 GMT] INFO Metrics server started on port 4001
[Thu, 03 May 2012 14:56:37 GMT] INFO Creating 1 worker process.

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
Error: Cannot find module './stores/mongodb'
    at Function._resolveFilename (module.js:332:11)
    at Function._load (module.js:279:25)
    at Module.require (module.js:354:17)
    at require (module.js:370:17)
    at [object Object].createStore (/usr/local/lib/node_modules/geddy/lib/sessions/index.js:26:23)
    at [object Object].<anonymous> (/usr/local/lib/node_modules/geddy/lib/app.js:137:20)
    at [object Object].runItem (/usr/local/lib/node_modules/geddy/lib/utils/async.js:108:10)
    at [object Object].<anonymous> (/usr/local/lib/node_modules/geddy/lib/utils/async.js:113:12)
    at Array.0 (/usr/local/lib/node_modules/geddy/lib/utils/async.js:148:54)
    at EventEmitter._tickCallback (node.js:192:40)
[Thu, 03 May 2012 14:56:37 GMT] ERROR Worker 736 died.
Contributor

meshachjackson commented May 3, 2012

I installed mongodb-wrapper inside the global geddy/node_modules dir, and I get a new error.


[Thu, 03 May 2012 15:10:30 GMT] DEBUG ============================================================
[Thu, 03 May 2012 15:10:33 GMT] ERROR [object Object]

/usr/local/lib/node_modules/geddy/node_modules/mongodb-wrapper/node_modules/mongodb/lib/mongodb/db.js:240
    throw new Error("db object already connecting, open cannot be called multi
          ^
Error: db object already connecting, open cannot be called multiple times
    at [object Object].open (/usr/local/lib/node_modules/geddy/node_modules/mongodb-wrapper/node_modules/mongodb/lib/mongodb/db.js:240:11)
    at open (/usr/local/lib/node_modules/geddy/node_modules/mongodb-wrapper/lib/mongodb-wrapper.js:625:20)
    at [object Object].connection (/usr/local/lib/node_modules/geddy/node_modules/mongodb-wrapper/lib/mongodb-wrapper.js:618:9)
    at connection (/usr/local/lib/node_modules/geddy/node_modules/mongodb-wrapper/lib/mongodb-wrapper.js:190:18)
    at [object Object].save (/usr/local/lib/node_modules/geddy/node_modules/mongodb-wrapper/lib/mongodb-wrapper.js:342:9)
    at [object Object].write (/usr/local/lib/node_modules/geddy/lib/sessions/stores/mongodb.js:101:32)
    at [object Object].close (/usr/local/lib/node_modules/geddy/lib/sessions/index.js:112:19)
    at [object Object].<anonymous> (/usr/local/lib/node_modules/geddy/lib/base_controller.js:447:24)
    at [object Object].<anonymous> (/usr/local/lib/node_modules/geddy/lib/base_controller.js:715:17)
    at EventEmitter.<anonymous> (/usr/local/lib/node_modules/geddy/lib/base_controller.js:745:13)
[Thu, 03 May 2012 15:10:33 GMT] ERROR Worker 1001 died.```
Contributor

Techwraith commented May 3, 2012

Very odd, can you post the results of this:

node -v
geddy -v
mongo --version

Thanks!

Contributor

meshachjackson commented May 3, 2012

$ node -v
v0.6.15
$ geddy -v
0.4.1
$ mongo --version
MongoDB shell version: 2.0.2

Contributor

meshachjackson commented May 3, 2012

FWIW: Here's the repo for my build.

https://github.com/meshachjackson/Geddy-Sample-App

git@github.com:meshachjackson/Geddy-Sample-App.git

Contributor

Techwraith commented May 3, 2012

So it looks like you're not providing a callback for the 'all' method on the adapter.

Contributor

meshachjackson commented May 3, 2012

If I start completely from scratch, I can get the same error with the following steps.

$ git clone https://github.com/mde/geddy.git
$ cd geddy/examples/todo_app_mongo
$ mkdir node_modules
$ npm install metrics
$ npm install mongodb-wrapper
$ geddy

This seems to load fine, then when I hit the url with a browser, I get the following in the terminal:

First, I get all the 'success' messages for starting the server...

[Thu, 03 May 2012 22:57:20 GMT] INFO Metrics server started on port 4001
[Thu, 03 May 2012 22:57:20 GMT] INFO Creating 1 worker process.
[Thu, 03 May 2012 22:57:20 GMT] INFO Server worker running in development on port 4000 with a PID of: 18459
[Thu, 03 May 2012 22:57:20 GMT] DEBUG LOGGING STARTED ============================================
[Thu, 03 May 2012 22:57:20 GMT] DEBUG ============================================================

... then, when I hit the url...

[Thu, 03 May 2012 22:57:29 GMT] ERROR [object Object]

/usr/local/lib/node_modules/geddy/node_modules/mongodb-wrapper/node_modules/mongodb/lib/mongodb/db.js:240
    throw new Error("db object already connecting, open cannot be called multi
          ^
Error: db object already connecting, open cannot be called multiple times
    at [object Object].open (/usr/local/lib/node_modules/geddy/node_modules/mongodb-wrapper/node_modules/mongodb/lib/mongodb/db.js:240:11)
    at open (/usr/local/lib/node_modules/geddy/node_modules/mongodb-wrapper/lib/mongodb-wrapper.js:625:20)
    at [object Object].connection (/usr/local/lib/node_modules/geddy/node_modules/mongodb-wrapper/lib/mongodb-wrapper.js:618:9)
    at connection (/usr/local/lib/node_modules/geddy/node_modules/mongodb-wrapper/lib/mongodb-wrapper.js:190:18)
    at [object Object].save (/usr/local/lib/node_modules/geddy/node_modules/mongodb-wrapper/lib/mongodb-wrapper.js:342:9)
    at [object Object].write (/usr/local/lib/node_modules/geddy/lib/sessions/stores/mongodb.js:101:32)
    at [object Object].close (/usr/local/lib/node_modules/geddy/lib/sessions/index.js:112:19)
    at [object Object].<anonymous> (/usr/local/lib/node_modules/geddy/lib/base_controller.js:447:24)
    at [object Object].<anonymous> (/usr/local/lib/node_modules/geddy/lib/base_controller.js:715:17)
    at EventEmitter.<anonymous> (/usr/local/lib/node_modules/geddy/lib/base_controller.js:745:13)
[Thu, 03 May 2012 22:57:29 GMT] ERROR Worker 18459 died.
Contributor

meshachjackson commented May 3, 2012

So it looks like you're not providing a callback for the 'all' method on the adapter.
@Techwraith

... Do you mean the index method in controller? I'm using the example code provided. Here's the method with the callback in place...

  this.index = function (req, resp, params) {
    var self = this;
    geddy.model.adapter.Todo.all(
        {status: {'in': ['open','done']}}
        , {sort: {status: -1, title: 1}}    
        , function(err, todos){
            self.respond({params: params, todos: todos});
        }
    );
  };
Contributor

Techwraith commented May 3, 2012

Looks like you don't have mongo running...

Sent from my iPhone

On May 3, 2012, at 3:57 PM, Meshach Jacksonreply@reply.github.com wrote:

If I start completely from scratch, I can get the same error with the following steps.

$ git clone https://github.com/mde/geddy.git
$ cd geddy/examples/todo_app_mongo
$ mkdir node_modules
$ npm install metrics
$ npm install mongodb-wrapper
$ geddy

This seems to load fine, then when I hit the url with a browser, I get the following in the terminal:

First, I get all the 'success' messages for starting the server...

[Thu, 03 May 2012 22:57:20 GMT] INFO Metrics server started on port 4001
[Thu, 03 May 2012 22:57:20 GMT] INFO Creating 1 worker process.
[Thu, 03 May 2012 22:57:20 GMT] INFO Server worker running in development on port 4000 with a PID of: 18459
[Thu, 03 May 2012 22:57:20 GMT] DEBUG LOGGING STARTED ============================================
[Thu, 03 May 2012 22:57:20 GMT] DEBUG ============================================================

... then, when I hit the url...

[Thu, 03 May 2012 22:57:29 GMT] ERROR [object Object]

/usr/local/lib/node_modules/geddy/node_modules/mongodb-wrapper/node_modules/mongodb/lib/mongodb/db.js:240
   throw new Error("db object already connecting, open cannot be called multi
         ^
Error: db object already connecting, open cannot be called multiple times
   at [object Object].open (/usr/local/lib/node_modules/geddy/node_modules/mongodb-wrapper/node_modules/mongodb/lib/mongodb/db.js:240:11)
   at open (/usr/local/lib/node_modules/geddy/node_modules/mongodb-wrapper/lib/mongodb-wrapper.js:625:20)
   at [object Object].connection (/usr/local/lib/node_modules/geddy/node_modules/mongodb-wrapper/lib/mongodb-wrapper.js:618:9)
   at connection (/usr/local/lib/node_modules/geddy/node_modules/mongodb-wrapper/lib/mongodb-wrapper.js:190:18)
   at [object Object].save (/usr/local/lib/node_modules/geddy/node_modules/mongodb-wrapper/lib/mongodb-wrapper.js:342:9)
   at [object Object].write (/usr/local/lib/node_modules/geddy/lib/sessions/stores/mongodb.js:101:32)
   at [object Object].close (/usr/local/lib/node_modules/geddy/lib/sessions/index.js:112:19)
   at [object Object].<anonymous> (/usr/local/lib/node_modules/geddy/lib/base_controller.js:447:24)
   at [object Object].<anonymous> (/usr/local/lib/node_modules/geddy/lib/base_controller.js:715:17)
   at EventEmitter.<anonymous> (/usr/local/lib/node_modules/geddy/lib/base_controller.js:745:13)
[Thu, 03 May 2012 22:57:29 GMT] ERROR Worker 18459 died.

Reply to this email directly or view it on GitHub:
mde#134 (comment)

Contributor

meshachjackson commented May 4, 2012

? I've got several other apps running with Mongo on the same machine. A few with express JS using a Mongoose connector.

I think the issue is related to the example app having 2 references to the same mongo conection info...

/todo_app_mongo/config/init.js

var mongo = require('mongodb-wrapper');

geddy.db = mongo.db('localhost', 27017, 'todo');
geddy.db.collection('todos');

// Add uncaught-exception handler in prod-like environments
if (geddy.config.environment != 'development') {
  process.addListener('uncaughtException', function (err) {
    geddy.log.error(JSON.stringify(err));
  });
}

/todo_app_mongo/config/development.js

/*
 * Geddy JavaScript Web development framework
 * Copyright 2112 Matthew Eernisse (mde@fleegix.org)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
*/

var config = {
  detailedErrors: true
, debug: true
, hostname: null
, port: 4000
, sessions: {
    server: {
        host : 'localhost'
      , port : 27017
      , db : 'testDB'
      , collection : 'sessions'
    }
  , store: 'mongodb'
  , key: 'sid'
  , expiry: 14 * 24 * 60 * 60
  }
, db: {
    mongo: {
      db: "todo"
    }
  }
};

module.exports = config;
Contributor

Techwraith commented May 4, 2012

Right! Sorry, tomorrow I'll give you a much more detailed overview of the fix for this, but for now, check out how the related_models example app is implemented. Model adapters are no longer required.

Sent from my iPhone

On May 3, 2012, at 5:09 PM, Meshach Jacksonreply@reply.github.com wrote:

? I've got several other apps running with Mongo on the same machine. A few with express JS using a Mongoose connector.

I think the issue is related to the example app having 2 references to the same mongo conection info...

/todo_app_mongo/config/init.js

var mongo = require('mongodb-wrapper');

geddy.db = mongo.db('localhost', 27017, 'todo');
geddy.db.collection('todos');

// Add uncaught-exception handler in prod-like environments
if (geddy.config.environment != 'development') {
 process.addListener('uncaughtException', function (err) {
   geddy.log.error(JSON.stringify(err));
 });
}

/todo_app_mongo/config/development.js

/*
* Geddy JavaScript Web development framework
* Copyright 2112 Matthew Eernisse (mde@fleegix.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*         http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

var config = {
 detailedErrors: true
, debug: true
, hostname: null
, port: 4000
, sessions: {
   server: {
       host : 'localhost'
     , port : 27017
     , db : 'testDB'
     , collection : 'sessions'
   }
 , store: 'mongodb'
 , key: 'sid'
 , expiry: 14 * 24 * 60 * 60
 }
, db: {
   mongo: {
     db: "todo"
   }
 }
};

module.exports = config;

Reply to this email directly or view it on GitHub:
mde#134 (comment)

@Techwraith Techwraith closed this May 30, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment