-
Notifications
You must be signed in to change notification settings - Fork 1
Setting up a production server
This document describes how CausalPath webserver can be run in a production environment using PM2 and Nginx.
Follow the guidelines in the README to download and run the app in the environment that the server will be hosted.
These instructions are tested on a VM with Ubuntu 20.04.
Assuming the server code is checked out to
/home/sammy/Code/causalpath-newt-webserver
and it is your current directory. sammy
is your username.
You have node version 14 installed under
/home/sammy/.nvm
The server runs fine with the below command
npm start
Now, stop the server with Ctrl+C and follow the below steps.
npm install pm2@latest -g
pm2 start npm --name CausalPath -- start
Make sure the server is running without problems after this command.
pm2 save
Type
pm2 startup systemd
This will print a message on the shell similar to the below.
[PM2] Init System found: systemd
[PM2] To setup the Startup Script, copy/paste the following command:
sudo env PATH=$PATH:/home/sammy/.nvm/versions/node/v14.20.0/bin /home/sammy/.nvm/versions/node/v14.20.0/lib/node_modules/pm2/bin/pm2 startup systemd -u sammy --hp /home/sammy
Copy and paste the last line (it will have your user name instead of sammy
, and maybe other differences) on the shell.
sudo env PATH=$PATH:/home/sammy/.nvm/versions/node/v14.20.0/bin /home/sammy/.nvm/versions/node/v14.20.0/lib/node_modules/pm2/bin/pm2 startup systemd -u sammy --hp /home/sammy
sudo apt update
sudo apt install nginx