Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mongod restart failed Ubuntu 18.04 #104

Open
hungrymonkey opened this issue Apr 11, 2020 · 5 comments
Open

Mongod restart failed Ubuntu 18.04 #104

hungrymonkey opened this issue Apr 11, 2020 · 5 comments

Comments

@hungrymonkey
Copy link

TASK [RocketChat.Server : Ensure the MongoDB service is started/enabled] ********************************************************************************************************************
fatal: [rocketchat.domain.tld]: FAILED! => {"changed": false, "msg": "Could not find the requested service mongod: host"}

requirements.yaml


- src: RocketChat.Server
  version: master
@hungrymonkey
Copy link
Author

hungrymonkey commented Apr 11, 2020

sudo systemctl status mongodb
● mongodb.service - An object/document-oriented database
   Loaded: loaded (/lib/systemd/system/mongodb.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2020-04-11 21:05:59 UTC; 9min ago
     Docs: man:mongod(1)
 Main PID: 2753 (mongod)
    Tasks: 23 (limit: 1152)
   CGroup: /system.slice/mongodb.service
           └─2753 /usr/bin/mongod --unixSocketPrefix=/run/mongodb --config /etc/mongodb.conf

Apr 11 21:05:59 ip-172-31-94-233 systemd[1]: Started An object/document-oriented database.
ubuntu@hostname:~$ sudo systemctl stop mongodb

systemctl status mongod
Unit mongod.service could not be found.
``

@hungrymonkey hungrymonkey changed the title Mongodb install failed Ubuntu 18.04 Mongod restart failed Ubuntu 18.04 Apr 11, 2020
@chrinats
Copy link

chrinats commented Aug 24, 2020

At /etc/ansible/roles/defaults/main.yml change

rocket_chat_mongodb_service_name: mongod
to
rocket_chat_mongodb_service_name: mongodb

@hungrymonkey
Copy link
Author

#101

@chrinats
Copy link

@hungrymonkey Did you manage to deploy Rocket.Chat?

I'm getting an error when executing MongoDb replica Set:

{"msg": "The conditional check '('ok' in (replSet_result.stdout | from_json))' failed. The error was: No JSON object could be decoded"}

@hungrymonkey
Copy link
Author

hungrymonkey commented Aug 25, 2020

@chrinats

I gave up and deployed the snap releases. This ansible does not seem to be maintained. You can peak at the effort to deploy the snapd below

https://docs.rocket.chat/installation/snaps

Rocket Chat Server

Home server URL

rocketchat.domain.com

Install

  1. Start Ubuntu AWS VM with Open Ports
    • 80 (TCP HTTP)
    • 443 (TCP HTTPS)
  2. Install Rocket Snap
    • sudo snap install rocketchat-server --channel=3.x/stable
  3. Setup Lets Encrypt
    • sudo snap set rocketchat-server caddy-url=https://rocketchat.domain.com
    • sudo snap set rocketchat-server caddy=enable
    • sudo snap set rocketchat-server https=enable
    • sudo snap run rocketchat-server.initcaddy
  4. Start Server
    • sudo systemctl restart snap.rocketchat-server.rocketchat-server.service
    • sudo systemctl restart snap.rocketchat-server.rocketchat-caddy.service
  5. Check Status
    • sudo service snap.rocketchat-server.rocketchat-server status
    • sudo service snap.rocketchat-server.rocketchat-mongo status
    • sudo service snap.rocketchat-server.rocketchat-caddy status

Deploy Automated Backups

  1. Move systemd/myrocketchat-backup.timer and systemd/myrocketchat-backup.service to /etc/systemd/system/
    • /etc/systemd/system/myrocketchat-backup.timer
    • /etc/systemd/system/myrocketchat-backup.service
  2. Enable the timer
    • sudo systemctl enable myrocketchat-backup.timer
  3. Start the timer
    • sudo systemctl start myrocketchat-backup.timer

Helpful tips

  1. View Logs
sudo journalctl -f -u snap.rocketchat-server.rocketchat-server
sudo journalctl -f -u snap.rocketchat-server.rocketchat-mongo
sudo journalctl -f -u snap.rocketchat-server.rocketchat-caddy

Common Errors

  1. Google Oauth2 - redirect_uri_mismatch
  • In the Authorized redirect URIs field, add both urls

    ```
    https://rocketchat.domain.com/_oauth/google
    https://rocketchat.domain.com/_oauth/google?close
    ```
    

Links

https://snapcraft.io/rocketchat-server

[Unit]
Description=Backup service for Rocketchat


[Service]
Environment=ROCKETCHAT_BACKUP_DIR=/var/snap/rocketchat-server/common/backup/
Type=oneshot
ExecStartPre=/usr/bin/sudo /usr/sbin/service snap.rocketchat-server.rocketchat-server stop 1
ExecStartPre=-/usr/bin/sudo /usr/bin/snap run rocketchat-server.backupdb 2
ExecStartPre=-/usr/bin/sudo /bin/sh -c 'aws s3 sync ${ROCKETCHAT_BACKUP_DIR} s3://domain-backups/rocketchat/$$(date +%%m-%%d-%%Y)/' 3
ExecStart=/usr/bin/sudo /bin/sh -c  '/bin/rm ${ROCKETCHAT_BACKUP_DIR}*; /usr/sbin/service snap.rocketchat-server.rocketchat-server start'
User=ubuntu
Group=systemd-journal

## Issue 1
## Snap has to be run with sudo
## permanently dropping privilege did not work: File exists

## Issue 2
## rm glob * become expanded when the service starts
## /var/snap/rocketchat-server/common/backup/ will be empty
## Moved the command to exec start so the glob will be
## populated properly
[Unit]
Description=Backup timer for Rocketchat
Requires=myrocketchat-backup.service

[Timer]
OnCalendar=Mon,Wed,Fri,Sun 02:00
Persistent=true

[Install]
WantedBy=timers.target

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants