You are here: Vanderbilt Biostatistics Wiki>Sandbox Web>PsNotes (revision 1)EditAttach

PS notes

Run test instance on my workstation

To rebuild the angular stuff after working on that part
cd ~/ps/inst/angular
npm run build

Run the application after rebuilding
cd ~/ps
./x.sh

Update the git repository after changes have been made

Navigate to the ps directory on my workstation
cd ~/ps

See what we have
git status

git add the changes I've made in the source code (this is some of the stuff in "Changes not staged for commit"). Here is an example of what might need to be done. Don't just copy and paste.
git add dichotModel.R
git status

Commit my changes
git commit -m "explanation of what was done"
git status

Recompile the compiled js
cd ~/ps/inst/angular/
npm run build

Clean up some. Remove stuff we don't want. Add other new stuff that was created by npm run build. These lines are examples of what might need to be done. Don't just copy and paste.
cd ~/ps
git status
git add inst/angular/dist/ps/index.html
git add inst/angular/dist/ps/main-es2015.f1b10667f2ebb1e98c3e.js
git add inst/angular/dist/ps/main-es5.f1b10667f2ebb1e98c3e.js
git add inst/angular/src/app/dichot/start/start.component.html
git add inst/angular/src/app/dichot/start/start.component.ts
git add inst/angular/src/app/version.ts
??git reset HEAD inst/angular/dist/ps/main-es2015.e8ec74816433e1f75eb8.js
??git reset HEAD inst/angular/dist/ps/main-es2015.e8ec74816433e1f75eb8.js
??git reset HEAD inst/angular/dist/ps/main-es5.e8ec74816433e1f75eb8.js

Commit again and push to github
git commit -m "after npm run build"
git push

Deploy to server

Install ansible if not already installed.
sudo apt install ansible

Clone or update the PS ansible repo
cd ~
git clone https://gitlab.app.vumc.org/stephej1/ps-ansible.git/

Run the ansible playbook to deploy to PS server virtual machine
cd ~/ps-ansible
ansible-playbook playbook.yml

Ansible configuration for PS...

... is at https://gitlab.app.vumc.org/stephej1/ps-ansible. Must make a VPN connection to access.

Coding for the application is done on the local workstation. Git is used for version control and the remote repository is on https://github.com.

PS virtual machine

  • hosted on biostat1553.dhcp.mc.vanderbilt.edu (10.151.20.93)
  • The virtual machine host name is biostat1553-ps (10.151.20.240)
  • There is a cron job that restarts the PS job every 30 minutes. We are doing this because something is causing the process to hang and become unresponsive.
    • 0,30 * * * * systemctl restart ps
  • Maybe have a look at /var/log/ps.log to see if there is any indication about what may be causing the hanging problem.

Setting up the local repository for the first time
(or starting from fresh because you've wrecked your local version)

Clone the repository
cd ~
git clone https://github.com/vubiostat/ps.git

Change to the ps directory
cd ps
git branch

The ~/ps/inst/angular/src/environments/environment.demo.ts file should look like this. The IP address is for the local computer where the work is being done.
export const environment: any = {
  production: false,
  apiUrl: "http://10.151.20.86:7788"
};

Make the environment file using the lines above.
touch ~/ps/inst/angular/src/environments/environment.demo.ts
vim ~/ps/inst/angular/src/environments/environment.demo.ts 

The ~/ps/inst/angular/package.json file should look like this:
 "name": "ps",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "node build.js",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^7.2.14",
    "@angular/common": "^7.2.14",
    "@angular/compiler": "^7.2.14",
    "@angular/core": "^7.2.14",
    "@angular/forms": "^7.2.14",
    "@angular/http": "^7.2.14",
    "@angular/platform-browser": "^7.2.14",
    "@angular/platform-browser-dynamic": "^7.2.14",
    "@angular/router": "^7.2.14",
    "@ng-bootstrap/ng-bootstrap": "^4.2.2",
    "core-js": "^2.6.5",
    "d3": "^4.9.1",
    "rxjs": "^6.5.1",
    "stable": "^0.1.6",
    "tslib": "^1.9.3",
    "zone.js": "^0.8.29"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.13.8",
    "@angular/cli": "7.3.8",
    "@angular/compiler-cli": "^7.2.14",
    "@angular/language-service": "^7.2.14",
    "@types/jasmine": "^2.8.16",
    "@types/jasminewd2": "^2.0.6",
    "@types/node": "~8.9.4",
    "codelyzer": "~4.2.1",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~1.7.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "^1.4.3",
    "karma-jasmine": "~1.1.1",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "^5.3.2",
    "ts-node": "~5.0.1",
    "tslint": "~5.9.1",
    "typescript": "~3.2.4"
  }
}

Create the~/ps/inst/angular/package.json file.
touch ~/ps/inst/angular/package.json
vim ~/ps/inst/angular/package.json

Install all the angular bits
By default, npm install will install all modules listed as dependencies in ~/ps/inst/angular/package.json.
cd ~/ps/inst/angular/
npm install

Build angular
npm run build

Make a file of R script that will be needed to run the R backend.
touch ~/ps/run-backend-demo.R

Contents of ~/ps/run-backend-demo.R
library(devtools)
load_all(".")
runPS("backend", "10.151.20.86")

Make a bash file to launch the app on this workstation.
cd ~/ps
touch x.sh

Contents of ~/ps/x.sh
#!/bin/bash
SESSION=ps
env="$1"
dir=`pwd`

tmux -2 new-session -d -s $SESSION -c "$dir/inst/angular" -n 'ed'
tmux new-window -t $SESSION:1 -n 'sh' -c "$dir/inst/angular"

tmux new-window -t $SESSION:2 -n 'ng' -c "$dir/inst/angular"
tmux send-keys "npm start -- -c demo" C-m

tmux new-window -t $SESSION:3 -n 'ng' -c "$dir/inst/angular"
tmux send-keys "CHROME_BIN=/usr/bin/chromium ng test --watch --source-map=false"

tmux new-window -t $SESSION:4 -c "$dir" -n 'R'
tmux send-keys "R --no-save < run-backend-demo.R" C-m

tmux -2 attach-session -t $SESSION

Launch the app on the local machine. It will be accessible at http://10.151.20.86:4200/ps or http://localhost:4200/ps.
cd ~/ps
chmod -x x.sh
./x.sh

Working on the code in the local repository

Set path to local repo
cd ~/ps 

Launch the app on the local machine. It will be accessible at http://10.151.20.86:4200/ps or http://localhost:4200/ps
cd ~/ps
./x.sh

Git commands...

git status   #Check current repository status
git branch   #See what branches are here
git stash   

git checkout master   #Make master branch current
git pull    #Sync local copy with repository

git push  # Push local changes to repository 
git log

Updating github repository after making changes on the local computer

Merge development branch into main if applicable

Rebuild angular
npm run build
cd ~/ps/inst/app

Stage the files that have been changed
cd ~/ps
git status
git add -u

Also stage an untracked file
inst/angular/dist/ps/main.???.js

Commit staged content
cd ~/ps
git status
git commit -m "explain the changes"

Transmit the local commits to the github repository
git push

Updating the server

Statcomp2 is the server for the PS application.

If changes are made in the PS code, we need to sync with the remote repository and, if any of the R has been changed, restart the R backend.

First, log on to the ps account on statcomp2. Use ssh from my Linux workstation that has the ssh key in place.
ssh ps@statcomp2.emp.vumc.io

Go to the PS directory
cd ~/ps  

Sync the code with the repository
git pull origin master 

Find the currently running backend process (only if R code has been changed)
ps ux

Kill the currently running backend process (only if R code has been changed)
kill ????    

Start a new backend process (only if R code has been changed)
./run.sh &    #

Check https://statcomp2.app.vumc.org/ps/ to be sure the changes are in the current app. Look at the build version and date. Might have to refresh.

Pegasus tickets for PS VM

Pegasus form Ticket submittedSorted ascending Ticket completed Pegasus id Notes
VUMC IP address request 20200608 20200609 R00641450 still need to update /etc/network/interfaces on VM
Create a new CI 20200608 20200608 CI biostatPS created within Pegasus but no ticket number generated
VUMC IT Linux-F5 LTM new VIP request 20200609 20200618 R00641452 External name: vbiostat.app.vumc.org (160.129.29.83)
Internal name: biostat1553-ps.emp.vumc.io (10.151.20.240)

The ticket (R00641450) requested a static IP.
SMITH, ROB
about 2 hours ago
Fulfilled with Notes: 'Please configure the IP settings of the device to use the following: 
IP address = 10.151.20.240 
subnet mask = 255.255.255.0 
gateway = 10.151.20.1 
DC1 DNS server = 10.108.51.18 
DC2 DNS server = 10.150.51.18 
DC3 DNS server = 10.101.62.234'


Edit | Attach | Print version | History: r5 | r4 < r3 < r2 < r1 | Backlinks | View wiki text | Edit WikiText | More topic actions...
Topic revision: r1 - 10 Feb 2021, DalePlummer
 

This site is powered by FoswikiCopyright © 2013-2022 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Vanderbilt Biostatistics Wiki? Send feedback