Hosting Test environment on Linux
In the page we describe the steps how to install the Thriot Services on a single Linux box running Ubuntu 14.04.2 LTS.
We assume that the Linux host is called ubuntuthriottesthost .
Please refer to the following table that defines the endpoints for the different services:
|Platform Websocket service||http://ubuntuthriottesthost:8080|
The backend storage is based on PostgreSQL 9.4 moreover we will need Mono 4.2.1, DNX (mono 1.0.0-rc1-final), and nginx to be installed.
Building for Linux
Execute the following command in the Service\Build forder (supposing the master branch of source code) on a Windows box to create a postgresql-based development/test package configured for Linux.
.\build.ps1 -config pgsql -configtmt pgsql -configmsg pgsql -copyConfigs yes -linuxify yes
Linux configuration just changes the nlog logfile target paths to /var/log/thriot/… and prepares some basic configs and scripts.
Compress the package to a single zip file and copy (pscp, scp, etc.) it to the /tmp directory to the linux host server.
cd /tmp unzip 201506062027_DevPgSql.zip
If there is no unzip command then execute sudo apt-get install zip and type unzipping the image again.
Fresh Ubuntu 14.04.2 LTS. Just OpenSSH server installed.
Installing PostgreSQL 9.4
Thriot was tested on PostgreSQL v 9.4, it may run on older versions but we will surely upgrade to 9.5 when it gets released.
Create the file /etc/apt/sources.list.d/pgdg.list, and add a line for the repository
deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main
Execute the following command as root:
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - apt-get update apt-get install postgresql-9.4
Installing Mono 4.2.1
To run Thriot on Linux currently Mono 4+ is needed which is not part of Ubuntu 14 LTS so we will need to get it directly from the Mono project’s website.
Create file /etc/apt/sources.list.d/mono-xamarin.list and add the following line for the repository
deb http://download.mono-project.com/repo/debian wheezy main
Execute the following command as root:
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF apt-get update apt-get install mono-complete
Setup thriot, thriottelemetry and thriotmessaging users with the same passwords as their names and create databases with similar naming conventions as set the appropriate user as owner.
Do not forget to impersonate as postgres user:
sudo su postgres psql
create user thriot password 'thriot' create user thriottelemetry password 'thriottelemetry' create user thriotmessaging password 'thriotmessaging' create database "Thriot" owner thriot; create database "ThriotTelemetry" owner thriottelemetry; create database "ThriotMessaging" owner thriotmessaging;
Step back to the original user (exit from postgres)
Setup password authentication for the thriot* users:
Edit the /etc/postgres/9.4/main/pg_hba.conf and add the following lines above the “local all all peer” setting:
#Thriot users local Thriot thriot md5 local ThriotTelemetry thriottelemetry md5 local ThriotMessaging thriotmessaging md5
Restart the postgresql service:
sudo service postgresql restart
To create the management database navigate to the /tmp/<UNZIPPEDPACKAGEPATH>/install/storage/management folder and execute the
mono Thriot.CreateSqlStorage.exe command.
In the messaging folder that’s adjacent to the management folder under storage execute the
cat CreateDB.sql | psql -U thriotmessaging -W -d ThriotMessaging
command to add the messaging-related entities to the database.
Preparing the thriot user
Run the following commands as root:
useradd thriot mkdir /opt/thriot mkdir /var/log/thriot chown thriot /opt/thriot chown thriot /var/log/thriot
Navigate to the folder of the install package and issue the following command:
sudo -u thriot cp -R api apihost msvc papi rapi web websocketservice /opt/Thriot
Setting up hosting and ports
Setting up nginx as reverse proxy
Since the different services of Thriot are running on different port numbers and it’s important for Thriot to provide consistent view to the outside world a reverse proxy is to be installed that can be configured to show all web services on the standard HTTP port and forward the request to the appropriate internal service ports.
sudo apt-get install nginx
Copy the configuration from the install package of install/configtemplates/nginxlinuxthriothost to /etc/nginx/sites-available, then create a link to this file under /etc/nginx/sites-enabled.
After setting up nginx configuration restart the nginx service by issuing the following command:
sudo service nginx restart
Setting up Url settings in the database
Setting up Thriot’s settings in the database:
Edit the install/storage/settings.sql according to your settings. In most cases the only thing that may have to be changed is the ubuntuthriottesthost name to your service’s public url.
Execute the following command to change settings:
cat /tmp/<UNZIPPEDPACKAGEPATH>/install/storage/settings.sql | psql -U thriot -W -d Thriot
Setting up .NET Executing Environment to host the web site
The .NET Execution Environment must be setup for the thriot user account.
Execute the following commands to install libuv that’s needed for running the Kestrel webserver:
sudo apt-get install automake libtool make curl curl -sSL https://github.com/libuv/libuv/archive/v1.4.2.tar.gz | sudo tar zxfv - -C /usr/local/src cd /usr/local/src/libuv-1.4.2 sudo sh autogen.sh sudo ./configure sudo make sudo make install sudo rm -rf /usr/local/src/libuv-1.4.2 && cd ~/ sudo ldconfig
Add the dnvm environment:
sudo su thriot curl -sSL https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.sh | DNX_BRANCH=dev sh && source ~/.dnx/dnvm/dnvm.sh
Exit the thriot user context and run
sudo su thriot
Currently we are using the beta7 version of DNX. So this version should be installed by issuing the following command
dnvm install 1.0.0-rc1-final
dnvm alias default 1.0.0-rc1-final
As thriot user copy the install/run.sh from the package to /opt/thriot
Mark run.sh as executable:
cd /opt/thriot chmod +x run.sh
Setting up API url’s for the Central website
Edit /opt/thriot/web/wwwroot/config/siteRoots.config to have the correct API root paths for the management and reporting APIs.
Execute the service
Execute the following commands every time you want to test using Linux hosting:
sudo su thriot cd /opt/thriot ./run.sh
If everything is fine you some see something like the following (running mono processes):
You may need to adjust the DNS or the hosts file on the system that runs the client to resolve the ubunutthriottesthost (or the host name you configured) correctly.
Execute the integration tests to verify if the system is up and running. The easiest way is to run the integration tests of the .NET client using the proper test settings config by selecting TestRunSettings\LinuxDevPgSql.runsettings in Test/Test Settings/Select Test Settings file menu option.
To upgrade to a newer/newest version do the following steps:
- Get the latest source snapshot
- Do a full rebuild with the appropriate configuration
- Execute the Management storage creator application (CreateSqlStorage) which won’t delete any data just upgrade the DB schema
- For the Messaging storage execute the appropriate CreateDB.sql script for PgSql targets
- Update the binaries
- Execute all unit/integration tests