Hi, when mongodb crash, i need to restart trudesk service.
Case :
Version 1.0.8
Trudesk and mongodb are running, i stop mongodb service and try to click on trudesk ihm :
i get this error on browser and syslog :
Error: MongoDb Error
at /opt/trudesk/src/middleware/index.js:57:17
at Layer.handle [as handle_request] (/opt/trudesk/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/opt/trudesk/node_modules/express/lib/router/index.js:317:13)
… etc…
trudesk status service is : Active: active (running)
Purpose : To maintain the application up and to automate the trudesk service restart, could you plan to enter in “failure mode”, with a browser and a syslog alerts, so that i could automate the restart of this service ?
Thank you so much your product is Amazing.
I m running one instance on Raspberry PI3 (V1.0.8) and mongodb database on Rock64 (3.6.10 unsupported on Raspberry PI).
I understand it throws that error, but the trudesk server shouldn’t crash. If you start MongoDB again Trudesk should pick back up without needing to restart. That error is just a route error that it failed to load a connection to Mongo during page load. It should continue to poll for the connection and once MongoDB is back up it will resume handling the routes.
Thank you, i agree with you, trudesk should not go in failure and continue to poll for the connection but in my case, i ve restarted the mongodb server and trudesk stay in the described state.
I just tested with my local environment. I stopped the mongodb service and refresh the browser. Got the same her you ref in OP. I then started the service and waited about 20 sec and refreshed the browser. Trudesk picked the connection back up and loaded the page. This is the correct behavior. The error that is through is a route middleware that checks the connection state before proceeding.
Was there a certain page you were trying to load after starting the MongoDB Service back. For me it was /tickets
i just done your test, may be, there is an issue with the mongodb stack on armhf …
logs :
Mar 26 10:52:48 raspi2 node[3297]: 3/26 10:52:48 [3297] - #033[33mwarn#033[39m: message=Topology was destroyed, stack=MongoError: Topology was destroyed
Mar 26 10:52:48 raspi2 node[3297]: at initializeCursor (/opt/trudesk/node_modules/mongodb-core/lib/cursor.js:766:25)
Mar 26 10:52:48 raspi2 node[3297]: at nextFunction (/opt/trudesk/node_modules/mongodb-core/lib/cursor.js:591:12)
Mar 26 10:52:48 raspi2 node[3297]: at AggregationCursor.Cursor.next (/opt/trudesk/node_modules/mongodb-core/lib/cursor.js:833:3)
Mar 26 10:52:48 raspi2 node[3297]: at AggregationCursor.Cursor._next (/opt/trudesk/node_modules/mongodb/lib/cursor.js:211:36)
Mar 26 10:52:48 raspi2 node[3297]: at fetchDocs (/opt/trudesk/node_modules/mongodb/lib/operations/cursor_ops.js:209:12)
Mar 26 10:52:48 raspi2 node[3297]: at toArray (/opt/trudesk/node_modules/mongodb/lib/operations/cursor_ops.js:239:3)
Mar 26 10:52:48 raspi2 node[3297]: at executeOperation (/opt/trudesk/node_modules/mongodb/lib/utils.js:420:24)
Mar 26 10:52:48 raspi2 node[3297]: at AggregationCursor.Cursor.toArray (/opt/trudesk/node_modules/mongodb/lib/cursor.js:824:10)
Mar 26 10:52:48 raspi2 node[3297]: at countDocuments (/opt/trudesk/node_modules/mongodb/lib/operations/collection_ops.js:218:37)
Mar 26 10:52:48 raspi2 node[3297]: at executeOperation (/opt/trudesk/node_modules/mongodb/lib/utils.js:420:24)
Mar 26 10:52:48 raspi2 node[3297]: at Collection.countDocuments (/opt/trudesk/node_modules/mongodb/lib/collection.js:1433:10)
Mar 26 10:52:48 raspi2 node[3297]: at NativeCollection.(anonymous function) [as countDocuments] (/opt/trudesk/node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js:146:28)
Mar 26 10:52:48 raspi2 node[3297]: at model.Query. (/opt/trudesk/node_modules/mongoose/lib/query.js:2125:31)
Mar 26 10:52:48 raspi2 node[3297]: at model.Query._wrappedThunk [as _countDocuments] (/opt/trudesk/node_modules/mongoose/lib/helpers/query/wrapThunk.js:16:8)
Mar 26 10:52:48 raspi2 node[3297]: at process.nextTick (/opt/trudesk/node_modules/kareem/index.js:369:33)
Mar 26 10:52:48 raspi2 node[3297]: at process._tickCallback (internal/process/next_tick.js:61:11), name=MongoError
Mar 26 10:52:48 raspi2 node[3297]: 3/26 10:52:48 [3297] - #033[33mwarn#033[39m: Topology was destroyed
I’ve seen this before when testing on my RP3. So if you don’t touch the mongo service after getting that error and just restart trudesk it connects back up and everything is fine?
Exactly, so don’t waste more time with this issue. I will manage adding some code at this line to put nodejs in failure and to parameter service to restart on failure . Thank you so much
And add to file [Dir install trudesk]/src/middleware/index.js
after line 56
app.use(function (req, res, next) {
if (mongoose.connection.readyState !== 1) { process.exit(1)
var err = new Error(‘MongoDb Error’)
err.status = 503
return next(err)
}
I just tested :
i stopped mongo service
i waited for 20 sec,
i restarted mongod service,
trudesk service restarted automatically.