Mesh/SudoPad

From Sudo Room
Revision as of 12:40, 12 July 2018 by Gcg (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This is a place for providing instructions, documenting changes, and troubleshooting problems regarding SudoPad, the etherpad-lite instance running on the sudomesh server.

Etherpad lite is a real time collaborative editor which allows multiple users to simultaneously work with the same document.

SudoPad is available at https://peoplesopen.net/pad or https://peoplesopen.net:9001. Documentation regarding etherpad can be found in its repo, https://github.com/ether/etherpad-lite.

Troubleshooting

If you receive an nginx error (like 503 bad gateway) when going to https://peoplesopen.net/pad:

  • Try going to https://peoplesopen.net:9001
  • If this also fails, start (or restart) the etherpad instance by logging into sudomesh server and running,
  sudo start etherpad-lite

Setting up an etherpad-lite instance

The following are the instructions that were used to install our instance of etherpad-lite and could be used to reinstall the instance from scratch. Instructions adapted from https://help.ubuntu.com/community/Etherpad-liteInstallation.

1. Add a new etherpad-specific system user, etherpad should never be run as root in production.

  sudo adduser --system --home=/opt/etherpad --group etherpad-lite

2. Install prequistes, some of these may already be installed, but it is always good to check that they are up-to-date,

  sudo apt update
  sudo apt install gzip git-core curl python libssl-dev build-essential abiword python-software-properties

3. Next, you'll need to install Node.JS and NPM as the etherpad-lite user,

  sudo su - etherpad-lite -s /bin/bash 
  curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
  export NVM_DIR="$HOME/.nvm"  # or you can close and reopen your terminal before using nvm
  nvm install 7.10

4. Install and test etherpad-lite with following command,

  sudo su - etherpad-lite -s /bin/bash 
  mkdir -p ~/local/etherpad
  cd ~/local/etherpad
  git clone git://github.com/ether/etherpad-lite.git
  cd etherpad-lite
  bin/run.sh 

5. Etherpad should now be running manually, you can check by going to <hostname>:9001 6. However, you will want to set up etherpad as a service that can be run in the background, to do this,

  sudo mkdir /var/log/etherpad-lite
  sudo chown etherpad /var/log/etherpad-lite
  sudo chown -R etherpad /var/log/etherpad-lite
  sudo nano /etc/init/etherpad-lite.conf

7. In the etherpad-lite.conf file paste the following:

  description "etherpad-lite"
  start on started networking
  stop on runlevel [!2345]
  env EPHOME=/opt/etherpad/local/etherpad/etherpad-lite  
  env EPLOGS=/var/log/etherpad-lite
  env EPUSER=etherpad-lite
  pre-start script
     cd $EPHOME
     mkdir $EPLOGS                              ||true
     chown $EPUSER:admin $EPLOGS                ||true
     chmod 0755 $EPLOGS                         ||true
     chown -R $EPUSER:admin $EPHOME/var         ||true
     $EPHOME/bin/installDeps.sh >> $EPLOGS/error.log || { stop; exit 1; }
  end script
  script
     cd $EPHOME/
     exec su -s /bin/sh -c 'exec "$0" "$@"' $EPUSER -- node node_modules/ep_etherpad-lite/node/server.js \
                       >> $EPLOGS/access.log \
                       2>> $EPLOGS/error.log
  end script

8. Assuming everything worked correctly, you should be able to start the etherpad service,

  sudo start etherpad-lite

9. Check if it worked by going again to <hostname>:9001

Setting up the MySQL database

You may have noticed a warning about DirtyDB in the logs when you started the service. It is advised that you do not use DirtyDB in production, instead, we'll setup a MySQL database for etherpad in our existing MySQL server.

1. First, assumming that MySQL is already installed and configured on the server, log into the MySQL server as root,

  mysql -u root -p

2. Once in MySQL, execute the following commands,

  create database `etherpad-lite`;
  grant all privileges on `etherpad-lite`.* to 'etherpad'@'localhost';
  exit

3. Now go to the ethepad config file with,

  sudo nano /opt/etherpad/local/etherpad/etherpad-lite/settings.json

and change the settings to match the priveleges you just granted, replacing the default dbType categories with the following,

  "dbType" : "mysql",
     "dbSettings" : {
         "user"    : "etherpad", 
         "host"    : "localhost", 
         "database": "etherpad-lite"
         "charset" : "utf8mb4"
      },

4. Restart the service and go to <hostname>:9001 to enable the new settings and check that the instance is still working.

5. Finally, back on the server, we'll need to change a few of the database's settings to do this, log into the MySQL server with,

  mysql -u root -p

and then execute the following commands,

  ALTER DATABASE `etherpad-lite` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
  USE `etherpad-lite`;
  ALTER TABLE `store` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
  exit

6. To set backups of the etherpad-lite database...


Setting up log rotation

Explain what log rotation does? Why is it neccessary?

1. Create a logrotate config file with,

  sudo nano /etc/logrotate.d/etherpad-lite

2. Copy and paste the following into this file,

  /var/log/etherpad-lite/*.log
  {
     rotate 4
     weekly
     missingok
     notifempty
     compress
     delaycompress
     sharedscripts
     postrotate
        restart etherpad-lite >/dev/null 2>&1 || true
     endscript
  }

3. Check that it is working with,

  logrotate -d /etc/logrotate.d/etherpad-lite

TODOs

  • setup/check-on the timetable for clearing abandoned pads