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

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 <whatever I've been working on>
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

Update local git repo. See PSNoteRegardingGit

Deploy to server

Install ansible if not already installed.
sudo apt install ansible

Clone or update the PS ansible repo (if not already present)
cd ~
git clone

Run the ansible playbook to deploy to PS server virtual machine. Ansible updates the working copy on the server, recompiles, and restarts the app.
cd ~/ps-ansible
ansible-playbook playbook.yml

Ansible configuration for PS...

... is at 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

PS virtual machine

  • The PS app root directory is /var/www/ps
  • The virtual machine is hosted on (
  • The virtual machine host name is biostat1553-ps (
  • 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

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: ""

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
runPS("backend", "")

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

Contents of ~/ps/

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 or http://localhost:4200/ps.
cd ~/ps
chmod -x

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 or http://localhost:4200/ps
cd ~/ps

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

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.

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)
./ &    #

Check 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 submitted Ticket completedSorted ascending Pegasus id Notes
Create a new CI 20200608 20200608 CI biostatPS created within Pegasus but no ticket number generated
VUMC IP address request 20200608 20200609 R00641450 still need to update /etc/network/interfaces on VM
VUMC IT Linux-F5 LTM new VIP request 20200609 20200618 R00641452 External name: (
Internal name: (

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

Topic revision: r3 - 12 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