Autorestarting rocketchat.service possible?

Before I say anything, I am completely new at this so I apologize if anything is wrong. I’m still learning. Is it possible to have the rocketchat service auto restart if it crashes or fails?

Server Setup Information

  • Version of Rocket.Chat Server: 3.17.1
  • Operating System: Ubuntu 20.04.3
  • MongoDB Version: 4.0.3

I’m waiting for an error to happen again to get help on the particular issue, but I’ve noticed a few times rocket chat has returned a Bad Gateway error a few times almost randomly. When I log in and use: sudo systemctl status rocketchat.service, I get an error that the service is no longer active and failed. I can restart the service just fine but after a few days or hours it will fail again.

I hope to figure that out but in the meantime. Does anyone have experience with Monit? I’ve been trying to figure out a way to automatically restart the service when these things happen, but I’m not sure if I understand how to set this up correctly? or if this is a good way to approach the problem.

Where would a pid file be located be located with rocket.chat?

Thanks for any help

Please advise your install type. This sort of info is very important.

Have a read through this on how to prepare a well documented question that has a better chance of an answer:

Note that just restarting without getting to the bottom of the issue is not good sysop practice.

Much better to solve the real issue rather than just sticking a plaster over it.

So check your logs carefully for issues if you you are using a snap read this: