Pak Jiddat - Innovative Software Services

Read: In the name of thy Lord Who createth, Createth man from a clot. Read: And thy Lord is the Most Bounteous, Who teacheth by the pen, Teacheth man that which he knew not. Nay, but verily man is rebellious That he thinketh himself independent!. Lo! unto thy Lord is the return. (Sura Alalaq 96:8)

Rocket Chat startup script

Created On: 12 Jan, 2017: 16:11:21 - Tags : software installation

Url: https://rocket.chat/

The following script can be used to run an instance of Rocket Chat:


#!/bin/sh

if [ $(ps -e -o uid,cmd | grep $USER | grep rocketchat | grep -v grep | wc -l | tr -s "\n") -eq 0 ]
then
        export PATH=/usr/local/bin:$PATH
        export MONGO_OPLOG_URL=mongodb://localhost:27017/local
        export ROOT_URL=http://your-domain/
        export MONGO_URL=mongodb://localhost:27017/your-database
        export PORT=1000
        export MAIL_URL=smtp://gmail_email_address:password@smtp.gmail.com:465
        /root/.nvm/versions/node/v4.5.0/bin/forever start --minUptime 1000 --spinSleepTime 10000 --sourceDir path-to-rocket-chat main.js -l /var/log/forever.log -o /var/log/forever-out.log -e /var/log/forever-err.log
fi

The above command checks if an instance of Rocket Chat is already running. If it is not running, then the Rocket Chat is run using the forever command. The forever command ensures that the Rocket Chat keeps running. It restarts the Rocket Chat automatically in case it stops. The forever script can be installed with the command: npm install forever. The above script may be run when the system boots up using the following cron job command: @reboot /root/scripts/rc_starter.sh > /dev/null 2>&1


Related Articles

  1. Upgrading Postgresql from version 9.4 to 9.6
  2. Installing latest version of Php
  3. Upgrading MySQL server from version 5.6 to 8.0
  4. Upgrading R from version 3.0 to 3.5
  5. Using PSCP command for copying files and directories
  6. Installing Docker on Debian Jessie
  7. Upgrading Rocket Chat to latest version
  8. Rocket Chat migration error
  9. Installing modules in Odoo 10.0
  10. Installing NodeJS on Ubuntu
  11. Installing W3C Markup Validator on Debian Jessie