Installation Nodejs and the Main Application - kwantu/platformconfiguration GitHub Wiki

back to Installation

Enable yum to run behind the proxy for DPW

This can be easily achieved with yum config file “/etc/yum.conf“. Under main section define the proxy settings like below:

vim /etc/yum.conf
...
[main]
proxy=http://10.123.227.33:3128
https-proxy=http://10.123.227.33:3128

Install the gcc compiler and development tools

yum install centos-release-scl
yum group install "Development Tools"
yum install gcc gcc-c++ kernel-devel make
  1. Then install npm
yum install npm

Once again, if there is a proxy then tell npm where to find it.

#DRDLR
npm config set proxy http://10.131.100.135:3128
#DPW
npm config set proxy http://10.123.227.33:3128
npm config set https-proxy http://10.123.227.33:3128
npm config set strict-ssl false

Then create and clone the betterdata application

  1. Create the kwantu user and the folder
sudo su -
useradd kwantu
cd /opt
mkdir betterdata-mobile
cd betterdata-mobile

# change the ownership to the kwantu user
chown -R kwantu:kwantu /opt/betterdata-mobile

# change to the new kwantu user
sudo su - kwantu
cd /opt/betterdata-mobile/
  1. Then clone the betterdata app from github
# Note that you need the valid token. Get it from the secure lastpass Vault.
git clone https://<token>@github.com/kwantu/mobile1.8.git

If there is a proxy server present, then tell github where to find it.

#DRDLR
git config --global http.proxy http://10.131.100.135:3128
#DPW
git config --global http.proxy http://10.123.227.33:3128

Install Node we are using the nvm installation approach

  1. Install nvm

Note that if there is a proxy server then make sure that the git global config is updated with the proxy.

sudo su - kwantu
cd /opt
sudo wget https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh
sudo chmod 755 install.sh
./install.sh
nvm install 12.8
  1. Then install the betterdata app using npm
cd /opt/betterdata-mobile/mobile1.8

npm install -g bower
npm install -g gulp
npm install -g pm2
npm install --only=prod
bower install

If you have a problem with bower requiring a proxy server then create the following .bowerrc is next to the bower.json. And if there is no .bowerrc file near the bower.json file, you can create one by yourself.

vim /opt/betterdata-mobile/mobile1.8/.bowerrc

Insert the following lines

#for EPWP
{
    "proxy":"http://10.123.227.33:3128",
    "https-proxy":"http://10.123.227.33:3128"
}

If you have a problem with the error ReferenceError: primordials is not defined

cd /opt/betterdata-mobile/mobile1.8
mv npm-shrinkwrap.json.backup npm-shrinkwrap.json
npm install
mv npm-shrinkwrap.json npm-shrinkwrap.json.backup

Prepare to start the application

We need to update the startup script to make sure that it will pull the correct version of the built application. And then start it and monitor the logs to make sure that it starts. But before we do that, we need to complete the DB server installation.

cd /opt/betterdata-mobile/mobile1.8 
sh /opt/betterdata-mobile/mobile1.8/installation/build.sh PROD01
tail -f ~/.pm2/logs/mobile1-8-out-0.log

Note that the parameter 'PROD01' should be the correct one for the version of the code that you are running.

Create a script that will ensure that this is done by the kwantu user, that may only be called by the root user

vim /opt/buildNode.sh
#
cd /opt/betterdata-mobile/mobile1.8
/bin/su -c '/bin/echo starting betterdata; cd /opt/betterdata-mobile/mobile1.8; sh /opt/betterdata-mobile/mobile1.8/installation/build.sh PROD01 &' - kwantu

Then create and clone the kwantu Portal

  1. Create the kwantu user and the folder
sudo su -
useradd kwantu
cd /opt
mkdir kwantuPortal
cd kwantuPortal

# change the ownership to the kwantu user
chown -R kwantu:kwantu /opt/kwantuPortal

# change to the new kwantu user
sudo s - kwantu
cd /opt/
  1. Then clone the betterdata app from github
# Note that you need the valid token. Get it from the secure lastpass Vault.
git clone https://<token>@github.com/kwantu/kwantuPortal.git

cd /opt/kwantuPortal

npm install

First time setup

From here onwards not on Ansible. Once server is up we need to run

  1. create index service for all communities
  2. Publish community configuration for 29000 community
  3. set build access to 38 user to 0
  4. Run clearOutAllOldWorkers.xq for communities
  5. Run /db/kwantu-resource/_tools/updatePermissions.xq on new exist to set public services access.

Resetting the change feed control for the first time.

  1. In the mysql database go to mobile1_8.changes_feed_control
  2. Remove all the records.
  3. Insert the all_db record into the table
INSERT INTO `mobile1_8`.`changes_feed_control` (`db_name`,`bookmark`,`status`,`mode`, `type`)
VALUES ('all_dbs',0,'setup','setup', 'all_dbs');
...

To stop the application
```bash
sudo su - kwantu
pm2 stop all
⚠️ **GitHub.com Fallback** ⚠️