Install Sao in a production environment

Introduction

You moved your Tryton instance into production and are connecting with the desktop client. But Tryton also has a web client called Sao. In this guide we will install Sao and make it available to the network.

This guide builds upon the guide from https://discuss.tryton.org/t/deploying-tryton-with-a-python-virtual-environment

Because we have NginX running, we are placing Sao inside the webroot of NginX and not in the webroot we defined in the trytond.conf. This will offload the requests for files of Sao, but also makes it possible to use the same Sao for multiple instances.

Note: We assume the following:

  • Everything can be done as a normal user.
  • The webroot will be /srv/www and is a different location then the Tryton webroot.

Installing NVM

Instead of installing nodejs through the system packages, we install it using a script called nvm, the Node Version Manager. In that case everything stays in the users home directory and you can easily remove the data afterwards if needed.

You can download the script from GitHub - nvm-sh/nvm: Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions, check it and execute it or do it in one step (without checking)

testadmin@docsrv:~$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash

Info: When writing this, the version of the script is v0.39.5. Read GitHub - nvm-sh/nvm: Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions for more information and version of the installation.

Logout and login again to make nvm available in your environment. Now with nvm installed we can install nodejs with

testadmin@docsrv:~$ nvm install --lts

which installs the latest LTS version of nodejs. You can also install the latest stable release. For more information do a nvm --help

Installing Sao

Now we need to download the sourcecode of Sao to be compiled by nodejs.

Warning: The series of Sao MUST match the series of the server. The third digit of the version is not important, it just shows the bugfix release. So:

|  Sao   | server | Will it Work? |
+--------+--------+---------------+
| 5.4.3  | 5.4.11 |      Yes      |
| 5.4.3  | 5.6.3  |      No       |
| 5.6.6  | 5.6.2  |      Yes      |

When you have determined which version (e.g. 6.0) to use you can download the sourcecode with

testadmin@docsrv:~$ curl -LO https://downloads.tryton.org/<version>/tryton-sao-last.tgz

and unpack it

testadmin@docsrv:~$ tar -zxf tryton-sao-last.tgz

First rename the directory package to sao-<version> so you know what is inside that directory when you stop now and come back a year later.

testadmin@docsrv:~$ mv package sao-6.0

Enter the directory.

testadmin@docsrv:~$ cd sao-6.0

Now you are ready to compile Sao. Use the following command to do that:

testadmin@docsrv:~$ npm install --production --legacy-peer-deps

You will see a bunch of info scrolling over your screen. Also you probably will see some vulnerabilities messages, these are from packages needed to compile Sao.

Moving files to the webroot

Not all files in the sao-6.0 directory are needed for running Sao, so we are only copying over the files really needed.

Info: If you are still testing or have other reasons, you can always use the root you specified in your trytond.conf under the [web] section (Configuration file for Tryton — Tryton server) as the webroot.

First make sure the webroot /srv/www/sao exists, if not create it.

testadmin@docsrv:~$ sudo mkdir -p /srv/www/sao

Now copy over the needed data.

testadmin@docsrv:~$ sudo cp -r bower_components dist images locale sounds index.html /srv/www/sao

Cleanup some directories because there are files we don’t need

testadmin@docsrv:~$ sudo rm /srv/www/sao/dist/tryton-sao.{js,css}
testadmin@docsrv:~$ sudo rm /srv/www/sao/locale/*.po /srv/www/sao/locale/messages.pot

Add webroot to NginX configuration

Info: If you decided to not use the NginX webroot, you can skip this.

Last thing to do is to add the webroot to the configuration in NginX.

testadmin@docsrv:~$ sudo nano /etc/nginx/sites-available/trytond.conf

And add a new location inside the server tag.

location /sao {
  root /srv/www;
}

Test the new configuration to see if you made a mistake

testadmin@docsrv:~$ sudo nginx -t

After NginX is happy, reload NginX to make the new location available.

testadmin@docsrv:~$ sudo systemctl reload nginx

Open you webbrowser and go to <your-domain-or-ip-address>/sao/ and you will be greeted by the login screen of Sao. Login using your username and password and enjoy using Tryton.

Cleanup

If everything worked out well, you can cleanup your system by removing the different components.

testadmin@docsrv:~$ rm -Rf sao-6.0 tryton-sao-last.tgz .npm .nvm

Warning: Be carefull where you are when using -Rf in the remove command.

This was the last section of setting up a complete Tryton installation with pip and deploy it in production.
For the other parts see