Starting Rocketchat via Systemd fails at first time after boot

Hi,

Every time i reboot my Rocket.Chat Server it fails but after a systemctl restart rocketchat, rocketchat works.

Systemd status of rocketchat.service:
Sep 30 15:53:30 rocketchat rocketchat[697]: at Socket. (/opt/Rocket.Chat/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/connection/connection.js:246:50)
Sep 30 15:53:30 rocketchat rocketchat[697]: at Object.onceWrapper (events.js:315:30)
Sep 30 15:53:30 rocketchat rocketchat[697]: at emitOne (events.js:116:13)
Sep 30 15:53:30 rocketchat rocketchat[697]: at Socket.emit (events.js:211:7)
Sep 30 15:53:30 rocketchat rocketchat[697]: at emitErrorNT (internal/streams/destroy.js:64:8)
Sep 30 15:53:30 rocketchat rocketchat[697]: at _combinedTickCallback (internal/process/next_tick.js:138:11)
Sep 30 15:53:30 rocketchat rocketchat[697]: at process._tickCallback (internal/process/next_tick.js:180:9)
Sep 30 15:53:30 rocketchat systemd[1]: rocketchat.service: Main process exited, code=exited, status=1/FAILURE
Sep 30 15:53:30 rocketchat systemd[1]: rocketchat.service: Unit entered failed state.
Sep 30 15:53:30 rocketchat systemd[1]: rocketchat.service: Failed with result ‘exit-code’.

My first guess was that Rocketchat depens on Mongodb but mongodb is not started yet.
Is this correct?
And i so, how can i solve the problem?

My Setup:
OS: Debian 9.11
RC: 1.3.0
MongoDB Version: 4.0.12
MongoDB Engine: wiredTiger
NodeJS: v12.10.0

Thanks in advanced

you your instance is tar, you must first run mongodb in rocketchat unit trey supply in rocket unit
[Unit]
Description=RocketChat etc.
After=mongo*.* (the real name of you unit mongo file)

Try to add this line into [Service] section of rocketchat.service.

ExecStartPre=/bin/sh -c 'until nc -z localhost 27017; do sleep 1; done'
1 Like