===== System installation ===== This chapter will describe the process of installing the system on a new server. The steps in this document will require that the user has knowledge of the chosen linux distribution and has some sense of NodeJS and MongoDB administration. ==== Prerequisites ==== Track and Trace 2.0 can be installed on any Linux system able to run MongoDB, Nginx HTTP server and the NodeJS framework. This document will show the installation process on Ubuntu LTS 16.04 and the installation procedure will differ on different Linux distributions. There is no obvious reason why TnT2.0 would not run on a Windows server, but this has not yet been tested and verified. ==== Installation of requirements ==== === MongoDB 3.6 === First, enable the repository for Mongo 3.6 to be used, since Ubuntu 16.04 uses an older repo by default: sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5 echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list Update and install MongoDB 3.6 sudo apt-get update sudo apt-get install -y mongodb-org Now you should be able to start the mongod daemon. sudo service mongod start And after that you should be able to verify the installation by connecting to the mongodb database. mongo ** IMPORTANT ** To ensure that the mongo database starts on system reboot make sure to enable the service: sudo systemctl enable mongod.service === Nginx HTTP === Installation of the Nginx web server on Ubuntu 16.04 is straightforward: sudo apt-get update sudo apt-get install nginx sudo ufw allow 'Nginx HTTP' systemctl status nginx To enable our webapp and TnT2 Client web pages edit the nginx configuration for the default site. vi /etc/nginx/sites-enabled/default Add the following under the //location / // tag: location /app { alias /opt/node/TrackAndTrace2/apps/scanner; } location /client { alias /opt/node/TrackAndTrace2/client; } Change /opt/node/TrackAndTrace2 to whatever your install location is. After this, simply reload the nginx service and we're done. systemctl reload nginx ==== Install the Track and Trace 2.0 system ==== We need NodeJS and the npm package manager: sudo apt-get install curl curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - sudo apt-get install nodejs Now we create the installation directory and set the permissions to full access: sudo mkdir /opt/node cd /opt/node sudo chmod a+rwx . mkdir tnt2_[site]_[version] ln -s tnt2_[site]_[version] TrackAndTrace2 cd TrackAndTrace2 Download and install the Track and Trace 2.0 system: git clone -b [version] [gitrepo] Install the required NPM-packages: npm install Substitute the configuration with the right one. If none exists, edit the configuration file. cd config rm tntconfig.js ln -s tntconfig_[SITE].js tntconfig.js cd .. Install the PM2 process manager: sudo npm install pm2 -g pm2 startup Follow the instructions. Create the manifest archive directory: mkdir manifestArchive Add the proper configuration to the //manifestsources// collection of the MongoDB database pointed to by the configuration file. mongo use [database] db.manifestsources.insert( { "type" : "ftp", "host" : "[FTPHOST]", "port" : 21, "user" : "[FTPUSER]", "password" : "[FTPPASSWORD]", "description" : "[DESCRIPTION OF SOURCE]", "sendercode" : "[SENDERCODE ON MANIFEST]", "path" : "[PATH ON REMOTE SERVER]", "archiveto" : "[PATH TO ARCHIVE TO ON THE REMOTE SERVER]", "localarchiveto" : "/opt/node/TrackAndTrace2/manifestsArchive", "active" : true, "filter" : [ [ADD REGULAR EXPRESSIONS TO MATCH MANIFEST HERE] ] } ); exit; Start the services for the TnT2 system: cd /opt/node/TrackAndTrace2 npm run manifestimporter npm run manifestpoimporter npm run manifestvalidator npm run manifestbuilder npm run mappingimporter npm run storeroomimporter npm run userimporter npm run restservice npm run worker npm run integration pm2 save Verify that all services are running: pm2 list Check that there are no errors in the logs: pm2 logs Add the needed indexes to the database collections: mongo use [DATABASE] db.manifests.createIndex( {"parser.parsed":-1}); db.transactions.createIndex( {"timestamp":-1}); db.MQdata.createIndex( {q:1} ); db.items.createIndex( {parent_id:1} ); db.packs.createIndex( {parent_id:1} ); db.transactions.createIndex( {timestamp:1} ); exit There, the system is now installed and running. Make sure to log in to the client and set the active-flag on the active stores prior to importing manifests, otherwise the manifest import process will fail as there are no active stores.