I had to the systemd unit
[Unit]
Description=Trudesk - Helpdesk system
After=network.target
[Service]
User=trudesk
Group=trudesk
Type=simple
ExecStart=/usr/bin/node /opt/trudesk/app.js
Restart=on-failure
RestartSec=20
StartLimitInterval=30
StartLimitBurst=5
[Install]
WantedBy=multi-user.target
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.