Closed equick closed 10 years ago
Hi,
I resolved it by creating a gear with just nodejs and your git repo, then setting these vars:
rhc env set OPENSHIFT_MONGODB_DB_URL=mongodb://linux:linux@ds04444.mongolab.com:44444/ --app rhc env set OPENSHIFT_MONGODB_DB_USERNAME=linux --app uptime rhc env set OPENSHIFT_MONGODB_DB_PASSWORD=linux --app uptime rhc app restart --app uptime
@equick glad you figured it out! Pretty cool that you have this app on openshift talking to mongolab mongodb instance. Just curious, why did you choose mongolab over just using mongo on openshift?
The main reason was space. When an uptime gear is created, there is only 200MB space left which ran out after about a week when I was first testing this.
-bash-4.2$ rhc app-show nodejs --gear quota Gear Cartridges Used Limit
538c7d645973ca9b180000df mongodb-2.4 nodejs-0.10 0.8 GB 1 GB
Without mongodb in the gear, I get an extra 650MB (for nodejs.log).
-bash-4.2$ rhc app-show uptime --gear quota Gear Cartridges Used Limit
538a3b955973caa8a00003f3 nodejs-0.10 253 MB 1 GB
mongolab provides 500MB free plus it has a nice easy to use interface. I don't fully understand the storage requirements yet so before I can quote the costs back to the business, I need to play around with it a bit more.
I have run into one other problem connecting to mongolab where I intermittently get 503 service unavailable errors in uptime due to the following:
/var/lib/openshift/538a3b955973caa8a00003f3/app-root/runtime/repo/node_modules/mongoose/lib/utils.js:413
throw err;
^
TypeError: Cannot read property 'firstTested' of null
at IntervalBuilder.calculateDuration (/var/lib/openshift/538a3b955973caa8a00003f3/app-root/runtime/repo/lib/intervalBuilder.js:100:44)
at Array.async.auto.duration as 3
at listener (/var/lib/openshift/538a3b955973caa8a00003f3/app-root/runtime/repo/node_modules/async/lib/async.js:412:46)
at /var/lib/openshift/538a3b955973caa8a00003f3/app-root/runtime/repo/node_modules/async/lib/async.js:371:17
at Array.forEach (native)
at _forEach (/var/lib/openshift/538a3b955973caa8a00003f3/app-root/runtime/repo/node_modules/async/lib/async.js:26:24)
at taskComplete (/var/lib/openshift/538a3b955973caa8a00003f3/app-root/runtime/repo/node_modules/async/lib/async.js:370:13)
at Promise.taskCallback (/var/lib/openshift/538a3b955973caa8a00003f3/app-root/runtime/repo/node_modules/async/lib/async.js:396:21)
at Promise.
I'll look into it a bit more and update here if I find the fix.
Ah yes, the 1 GB of storage will run out rather quickly if you have verbose set to true. When I've set verbose to false, the logs grow much more slowly (I haven't had to clear them out in months for one of my instances)
If you can't turn verbose logging off, you could also look at upgrading the gear storage. You can get up to 30gb with the bronze/silver plans.
Not sure about that 503 error...
You need to turn off preallocation in the mongo config if you are going to stay on the free plan.
/var/lib/openshift/<your ID>/mongodb/conf/mongodb.conf
# Disable data file preallocation.
noprealloc = true
nopreallocj = true
# Specific configuration for openshift cartridge
smallfiles = true
quiet = true
Thanks, I had all those settings (by default) already apart from the nopreallocj. There is a verbose=true log setting in that file as well so I've switched that to false.
Hi rhmalik,
Do you know if it's possible to run this connecting to mongolab instead?
I set OPENSHIFT_MONGODB_DB_URL and OPENSHIFT_APP_NAME, and the collections were created but then it runs into this error:
Mongoose: taghourlystats.ensureIndex({ timestamp: -1, name: 1 }) { safe: undefined, background: true, unique: true } Mongoose: tagdailystats.ensureIndex({ timestamp: -1, name: 1 }) { safe: undefined, background: true, unique: true } Mongoose: tagmonthlystats.ensureIndex({ timestamp: -1, name: 1 }) { safe: undefined, background: true, unique: true } Mongoose: tagyearlystats.ensureIndex({ timestamp: -1, name: 1 }) { safe: undefined, background: true, unique: true } Mongoose: tags.ensureIndex({ name: 1 }) { safe: undefined, background: true, unique: true } Mongoose: checks.find({ '$where': 'function () {\n if (this.isPaused) return false;\n if (!this.firstTested) return true;\n var delay = (this.lastTested.getTime() - this.firstTested.getTime()) % this.interval;\n return (Date.now() - this.lastTested.getTime() + delay) >= (this.interval || 60000);\n}' }) { fields: { qos: 0 }, safe: undefined } Mongoose: pings.ensureIndex({ check: 1 }) { safe: undefined, background: true } { [MongoError: unauthorized] name: 'MongoError', ok: 0, errmsg: 'unauthorized' } DEBUG: Program node server.js exited with code 1