PostgreSQL-backed hosting environment

This page describes the steps how to install Thriot in fully PostgreSql (9.4+)-based runtime environment. It means that all management data, telemetry data and of course messages are stored in a PostgreSql 9.4+ database.

We will discuss the installation procedure of a single-box environment, where the responsibilities of the box are the following:

  • APIs and Services
    • Central website
    • Management API
    • Platform API
    • Platform Websocket Service
    • Reporting API
    • Messaging API (private)
  • Data storage
    • Management Database
    • Telemetry database
    • Messaging database

Based on this description with quite minimal phantasy you can find out how to install the system on multiple boxes or even scale it out to more servers. When scaling out please consider the following rules:

  • The APIs can be freely scaled out expect for the Messaging API
  • Messaging API should run in single instance mode (failover clustering is OK)
  • The Websocket service can be freely scaled out
  • The database can run in HA mode

For easier configuration please refer to the following page:

Server names used in this tutorial

This tutorial assumes that the target server is the following:

Of course you will install servers with different names, these are just examples. Ensure to use the correct names in all configurations and settings.


This tutorial supposes the release v0.6 of source code.

Having the source code you can use the following command the produce binaries with default PostgreSQL configuration:

src\Service\Build> .\build.ps1 -config pgsql -configtmt pgsql -configmsg pgsql -copyConfigs yes -linuxify no

The results will go to the output\{CURRENTDATE}_pgsql folder.

Please note that in case of upgrading (to be discussed in the Upgrading section below) the -copyConfigs parameter must not be used to ensure that no config files are accidentally overwritten.

The output folder contains the following subfolders:

Folder Description Type
api Management API REST API
msvc Messaging Service API REST API
papi Platform API REST API
rapi Reporting API REST API
web Central website Thin website
websocketservice Websocket Service Windows Service
install install\configtemplates – Configuration templates
install\storage\management – Program that initializes management storage
install\storage\messaging – Script to create Message database storage
Templates, scripts and applications
plugins Plugins for telemetry data and queueing Plugins


Install IIS

In Server Manager select Add roles and features.

Here tick the Web Server (IIS) Role.


Select the following role services:





Hit Next and do the installation.

Install HttpPlatformHandler

Follow this page to add HttpPlatformHandler:

On some environments it may be preinstalled.

Install PostgreSql

Download the Windows x64 installer of PostgreSql v 9.4+. The installers name must be something like this: postgresql-9.4.1-3-windows-x64.exe

Start the installer.

You can configure installation and database directory freely:


Set the superuser’s (postgres) password:


Assume that you leave the default 5432 port number and locale.

After successful installation, it’s optional to select anything from the stackbuilder.

Configuring databases

Start pgAdmin III and login using the postgres user account.

Create the following three users:

  • thriot
  • thriotmessaging
  • thriottelemetry

Choose secure password for the users.


Create 3 database:

  • Thriot – for management (set owner to thriot)
  • ThriotTelemetry – for storing telemetry data (set owner to thriottelemetry)
  • ThriotMessaging – for messaging (set owner to thriotmessaging)


You should see the following results after creating all tree users and databases (with the right owners):


To create management database entities from the build output select the install\storage\management folder and change the management database connection parameters (Thriot database in our case) in the Thriot.CreateSqlStorage.exe.config:


Execute the Thriot.CreateSqlStorage.exe:


Add new connection for the thiotmessaging user:


Login with the newly created connection and execute the install\messaging\CreateDb.sql script:


Create a new connection for the Thriot user and navigate to the Setting table in the Thriot database.

Select view top 100 rows and edit the rows according to the figure and table below:


Explanation of the configuration settings:

Category Setting Value
Connection TelemetryConnection Connection string for recording telemetry data in PostgreSQL.
Server=*******;Port=5432;Database=****;User Id=******;Password=*****;
Microservice MessagingServiceApiKey Shared secret for authenticating to the messaging service.
It’s an automatically generated value.
Microservice MessagingServiceEndpoint Messaging service url.It can be localhost for now since we are running on a single box.e.g.
Microservice TelemetrySetupServiceApiKey Shared secret for authenticating to the telemetry setup service.It’s an automatically generated value.
Microservice TelemetrySetupServiceEndpoint Telemetry setup service endpoint.
It can be localhost for now since we are running on a single box.
PublicUrl ManagementApiUrl Management API url.e.g.
PublicUrl PlatformApiUrl Platform API url.e.g.
PublicUrl PlatformWsUrl Platform Websocket url.e.g.
PublicUrl ReportingApiUrl Reporting API url.e.g.
PublicUrl WebsiteUrl Central website url.e.g.
Runtime EmailActivation Specify If email activation is required.For production environment should be true.
Runtime ServiceProfile ServiceProvider, SingleCompany or SingleService.ServiceProvider


Installing the web applications

Copy the api, msvc, papi, rapi, web, websocketservice and plugins folders to a newly created Thriot folder.


The configuration files folder is located at the following places respectively:
  1. c:\Thriot\api\approot\packages\Thriot.Management.WebApi\1.0.0\root\config\
  2. c:\Thriot\pap\approot\packages\Thriot.Platform.WebApi\1.0.0\root\config\
  3. c:\Thriot\rapi\approot\packages\Thriot.Reporting.WebApi\1.0.0\root\config\
  4. c:\Thriot\msvc\approot\packages\Thriot.Messaging.WebApi\1.0.0\root\config\
  5. c:\Thriot\web\wwwroot\config\
  6. c:\Thriot\websocketservice\config\

Prepare the config files in the following way:


    "ConnectionString": {
        "ManagementConnection": {
            "ConnectionString": "Server=;Port=5432;Database=Thriot;User Id=thriot;Password=****************",
            "ProviderName": "Npgsql"

Ensure to have the correct connection string instead of the examples above.

connectionstringmsg.jsong should look like this:

    "ConnectionString": {
        "MessagingConnection": "Server=;Port=5432;Database=ThriotMessaging;User Id=thriotmessaging;Password=****************"

Ensure to have the correct HTTP endpoints instead of the examples above.


siteroots.js (for the central website):

app.constant('siteRoots', {
   managementRoot: '',
   reportingRoot: ''

Ensure to have the correct HTTP endpoints instead of the examples above.


smtpsettings.json (for management api):

    "SmtpSettings": {
        "FromAddress": "",
        "FromName": "Thriot",
        "BouncesAddress": "",
        "Host": "",
        "Port": "587",
        "UserName": "***",
        "Password": "***"

Ensure to have the correct SMTP settings instead of the examples above.

If you are running an asp.net5 rc1 app under a virtual directory in IIS you need to do some workaround to support virtual directories. Thriot implements this by vdir.json config files.

vdir.json shoud look like this:

{“VDIR”: “/api”}
{“VDIR”: “/papi”}
{“VDIR”: “/rapi”}
{“VDIR”: “/msvc”}

respectively for management, platform, reporting and messaging services (they are reachable under api,, etc). The vdir.json has to be put under the regular config directory as the other configurations.


nlog.*.configs are fine for demoing if your working directory is C:\Thriot.


Create a website called Thriot and point it to the c:\Thriot\web\wwwroot folder. Ensure to delete or disable the Default Website first.


Create api Application for the Management API (right click the Thriot website / add application) – c:\Thriot\api\wwwroot:



Create papi Application for the Platform API- c:\Thriot\papi\wwwroot:



Create rapi Application for the Reporting API- c:\Thriot\rapi\wwwroot:



Create the msvc Application for the Messaging Services API- c:\Thriot\msvc\wwwroot:



The final structure should look like this if you look at the website in IIS Manager:



Installing the Websocket service

In the c:\Thriot\websocketservice run

c:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe Thriot.Platform.WebsocketService.exe


Setting up logging

Create a folder named c:\Thriot\log.

Add Modify permissions to this folder for iis apppool\thriot user.



Do the same for nt service\ThriotWebSocketService user.


Final steps

HTTP endpoint will be opened by default on the firewall, you should open the 8080 port for the websocket service.


To start the Windows service you can use the Service Control Manager (services.msc) or issue the following command from the command line:

net start ThriotWebSocketService

If you are running on Azure or behind a firewall do not forget to open the 80 and 8080 ports.

Testing if everything works fine

Now navigate to the address of the web frontend server, register a new user, accept the registration, login with the user, create new company, service, network and device. If everything works fine you can start using the .NET or Linux C++ client libraries.


To upgrade to a newer/newest version do the following steps:

  1. Get the latest source snapshot
  2. Do a full rebuild with the same parameters as for the first time but ensure that you specify -copyConfig no setting.
  3. Update the binaries
  4. Execute the Management storage creator application with the same connectionstring settings (CreateSqlStorage) which won’t delete any data just upgrade the DB schema
  5. For the Messaging storage execute the appropriate CreateDB.sql script, which won’t delete any data just upgrade the DB schema
  6. Do a smoke test