Setting up Process Managers and Init Systems
PM2
Systemd
Deploy Rocket.Chat to Linux that run on systemd (RedHat, Centos, Ubuntu, CoreOS and so on).
How to run Rocket.Chat on systemd.
First we need to create the unit file.
vi /etc/systemd/system/rocketchat.service
With the contents:
[Unit]
Description=Rocket.Chat Server
After=network.target remote-fs.target nss-lookup.target mongod.target nginx.target # Remove or Replace nginx with your proxy
[Service]
ExecStart=/usr/local/bin/node /var/www/rocketchat/main.js # Specify the location of node and location of main.js
Restart=always # If set to always, the service will be restarted regardless of whether it exited cleanly or not, got terminated abnormally by a signal, or hit a timeout.
RestartSec=10 # Restart service after 10 seconds if node service crashes
StandardOutput=syslog # Output to syslog
StandardError=syslog # Output to syslog
SyslogIdentifier=nodejs-example
#User=<alternate user>
#Group=<alternate group>
Environment=NODE_ENV=production PORT=3000 ROOT_URL=https://rocketchat.domain.com MONGO_URL=mongodb://localhost:27017/rocketchat
[Install]
WantedBy=multi-user.targetThen you need to enable the service systemctl enable rocketchat.service
To start the service systemctl start rocketchat.service
To verify it is running systemctl status rocketchat.service
Backup
All data will be hourly backed up to /data/domains/example.org/data folder. We advise to copy this folder to a remote location in case of hardware failure.
Upstart - Ubuntu
Note: Upstart is no longer supported. We no longer support Ubuntu 14.04. If upgrading please see systemd or Ubuntu 18.04
The following examples are upstart jobs which control automatic start-up and, if necessary, respawning of your Rocket.Chat app, as well as management of an optional hubot chat-bot.
In order to use the examples, simply copy each example and save into a file, paying attention to the fact that the filenames should be preserved unless you edit the examples to reflect any filename changes you make. Be sure to edit the environment variables, and possibly paths, according to your particular installation. Once you've saved the files to the proper directory (/etc/init) usage is as simple as rebooting.
Which upstart management jobs that you use depend on what type of Rocket.Chat deployment you are using (Docker-compose, non-docker, etc). A race-condition exists with docker compose which requires that mongo and the Rocket.Chat application be started independently, thus a slightly modified upstart job is required compared to non-docker instances.
Non-Docker-Compose
Save as: /etc/init/rocketchat.conf
Save as: /etc/init/rocketchat_hubot.conf
Docker-Compose
Save as: /etc/init/rocketchat_mongo.conf
Save as: /etc/init/rocketchat_app.conf