#########################
Setup from Scratch
#########################
Manual Setup installs each component individually to maximize control and configurability. All components can be installed into a single machine, provided the machine has an FQDN, and is strong enough to meet the requirements. Please make sure the certificate for the domain includes not only the domain itself, but all its belonging subdomains as well. You may ensure it by using a wildcard like "*.mydomain.com" when procuring the certificate.
******************
Setting Up Pavilion
******************
Requirements
============
* `Node.js `_ (>= 10.13.0, except for v13) (Windows Build Tools for Windows systems)
* `Yarn `_
* `NestCli `_
* `Postgres `_
Getting Started
===============
.. code-block:: bash
git clone https://github.com/doganbros/pavilion # Clone Repository
cd pavilion
Install dependencies with
.. code-block:: bash
yarn install
Set Environment Variables Into .env File
=======================================
You may configure the environment by making a copy of the boilerplate provided. The functionality of each environment variable is documented within the ``.env.example`` file.
.. code-block:: bash
cp .env.example .env # Then make changes to the boilerplate provided
.. list-table:: You can find a brief coverage of most prominent variables below.
:widths: 25 25 50
:header-rows: 1
* - Variable
- Example
- Explanation
* - NODE_ENV
- development
- The environment your application runs in.
* - SERVER_PORT
- 8000
- The port the backend server is running on.
* - PORT
- 3000
- The port the frontend serves from.
* - HOST
- pavilion.io
- Host address for backend and frontend.
* - PURPIE_API_KEY
- YOUR_API_KEY
- Key for access API directly with PURPIE_API_SECRET
* - PURPIE_API_SECRET
- YOUR_API_SECRET
- Secret for access API directly with PURPIE_API_KEY
* - RTMP_INGRESS_URL
- ingress.yourrtmp.com
- The RTMP server Pavilion pushes your streams to.
* - RTMP_EGRESS_URL
- egress.yourrtmp.com
- The RTMP server Pavilion pulls steams from to display.
Creating Postgres Database
========================
Please follow the steps below to get a development Postgres server running. The easiest way to use `docker `_. If you have running Postgres database server you can skip these steps and simply create an Pavilion database.
* Make sure you have docker installed on your computer. If you do not have docker already on your computer, Go to `this link `_, choose your platform and click download. Follow the simple steps to get docker installed on your computer.
* Open your terminal (command prompt or preferably powershell on windows).
* Enter the command ``docker run --name pavilion-dev -e POSTGRES_PASSWORD=$YOUR_POSTGRES_PASSWORD -p 5432:5432 -d postgres``. Postgres docker image will be downloaded and Postgres Docker container with the name pavilion-dev will up and serve from port 5432 after this command.
* Run ``docker exec -it pavilion-dev psql -U postgres`` to connect your Postgres database.
* Inside the docker container, run ``CREATE DATABASE 'pavilion';`` to create your Pavilion database.
* Run ``\q`` to quit from Psql and Docker container.
* Remember to update ``DB_USER``, ``DB_PASSWORD``, ``DB_DATABASE`` and ``DB_HOST`` .env variables to your database user name, database password database name, and database host respectively.
***************************************
Running Pavilion
***************************************
.. code-block:: bash
yarn server:start:dev # Runs backend side in dev mode
yarn start:server # Runs backend in production
yarn start:web # Runs frontend side
You may refer to this `sample NGINX config `_ to set up your Pavilion web server.
****************
Setting up Jitsi
****************
Installing Jitsi with JWT support
=================================
Pavilion mmakes use of Jitsi for video streaming and live meeting purposes. It requires a Jitsi installation with JWT token support. You can refer to `this document `_ by us to install Jitsi. Remember to update the ``.env`` variable by setting ``JWT_APP_ID``'s value to ``YOUR_APP_ID``, ``JITSI_SECRET`` to ``YOUR_SECRET`` and ``JITSI_DOMAIN`` to the domain where you set up jitsi.
Installing Pavilion Jitsi Module
------------------------------
This module is a React Module that applies on top of Jitsi to provide visual and functional differentiations. To avoid issues regarding version mismatch, start with the customized Jitsi repo below;
.. code-block:: bash
git clone https://github.com/doganbros/pavilion-jitsi-meet.git
cd pavilion-jitsi-meet
The module is included in the package.json file within the repository. Therefore, you are able to simply follow the promtps as shown;
.. code-block:: bash
npm install
export WEBPACK_DEV_SERVER_PROXY_TARGET=https://yourdomain.com
make
At this point, your customized Jitsi is built and ready to serve. Make sure to edit the NGINX configuration accordingly to make use of your new directory.
Integrating Jitsi with Pavilion
=================================
* This .lua module for Jitsi Meet manages the integration between pavilion and Jitsi. It enables Jitsi to send reports to Pavilion. To enable it, follow the instructions below.
.. code-block:: bash
cp ./external/prosody-modules/mod_pavilion.lua /usr/share/jitsi-meet/prosody-plugins
Configuring Prosody
-------------------
* Edit your prosody configuration at ``/etc/prosody/conf.d/your.domain.com.cfg.lua``, and add the following lines.
.. code-block:: lua
pavilionApiKey = "yourAPIkey";
pavilionApiSecret = "yourAPIsecret";
pavilionAPIBaseUrl = "https://your.baseAPI.url";
* In the same file, add pavilion to the list of enabled modules of the conference component like below;
.. code-block:: lua
Component "conference.meet.doganbros.com" "muc"
restrict_room_creation = true
storage = "memory"
modules_enabled = {
"muc_meeting_id";
"muc_domain_mapper";
"polls";
"pavilion";
"token_verification";
}
admins = { "focus@auth.meet.doganbros.com" }
muc_room_locking = false
muc_room_default_public_jids = true
Installing Jibri
================
To install Jibri you can follow `this tutorial `_.
Customizing the Finalize Script
--------------------------------
* Find the following in your ``/etc/jitsi/jibri/jibri.conf`` file, and replace path with ``/srv/finalize/pavilion-finalize.sh``
.. code-block:: lua
jibri {
recording {
finalize-script =
}
}
* Copy the included finalize.sh file to your finalize script directory. This .sh file runs upon the completion of recording, and both uploads the recorded file to an S3 bucket, and manages Jibri's integration with Pavilion.
.. code-block:: bash
cp {./external/jibri/pavilion-finalize.conf, pavilion-finalize.sh} /srv/finalize
* Edit ``/srv/finalize/pavilion-finalize.conf`` accordingly, and restart Jibri.
.. code-block:: bash
systemctl restart jibri
***************************************
Setting up the Ingress RTMP servers
***************************************
For Pavilion, you will need at least one ingress server, and as many additional egress servers as you need for ease of autoscalability. To install NGINX rtmp server, you can follow the guide in `this page `_. Remember to update the ``RTMP_INGRESS_URL`` and ``RTMP_EGRESS_URL`` .env variables to your ingress and egress server url respectively.
Integrating the RTMP server with Pavilion
=====================================
* Head into the RTMP server, and use the following to copy the required scripts. ``sample-nginx.conf`` contains a working example for an RTMP server, who calls upon ``pavilion.sh`` in its workflow. ``pavilion.sh`` is the script that maintains the integration between the RTMP server and Pavilion. ``pavilion-sh.conf`` contains customizable variables for the script.
.. code-block:: bash
mkdir /home/pavilion
cp {./external/rtmp/pavilion.sh, ./external/rtmp/pavilion-sh.conf} /home/pavilion
cp ./external/rtmp/sample-nginx.conf /etc/nginx
* Navigate to ``/home/pavilion`` and edit the contents of ``pavilion-sh.conf`` accordingly. Then restart nginx.
.. code-block:: bash
systemctl restart nginx