Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
# Adventrain Backend NodeJS http server
This repo contains the http server used for UConn Senior Design Project 33 - Adventrain.
## Depedendencies
- Access to sdp33.cse.uconn.edu and have root user/sudo access
- Putty or MobaXterm
- Other dependencies such as NodeJS, git etc are already installed on virtual machine globally
## Developer Instructions
### Cloning the git repo and installing dependencies
```
git clone https://github.uconn.edu/sus15102/adventrain_backend.git
```
Next enter the repo and install dependencies with NPM
```
cd adventrain_backend
npm install
```
After the dependencies are installed, the server is ready to run.
### Running the server with forver.js (PREFERED METHOD)
[Forever.js](https://www.npmjs.com/package/forever) is a node package that allows a script to be run in the background even after the bash session has expired or ended.
First go into the adventrain_backend directory within the serever and run the following:
```
forvever start server.js
```
Which will allow the script to be running in the background continously. To see a list of running jobs run:
```
forever list
```
To see the list of running processes and their ID. In this project this is the only process we will be using so the ID we need to remember is always 0. So to stop our foverever batch job we run:
```
forever stop 0
```
### Other Ways to run the server (past methods used until server port 8000 made public)
#### Running the Server with Ngrok
At this moment in time we are using ngrok to run the application as we are working with UConn ITS to be able to host the server on local host and allow external connection to localhost:8000. For the time being, we will be using ngrok to manually create our own connectable host url.
1. Run the server in one open tab (in the repository):
```
node server.js
```
2. Open a new window logged into the VM, then run the following:
```
ngrok http 8000
```
Now the server is up and running! To do the post and get requests you must use the URL provided on the ngrok screen as shown below:
```
ngrok by @inconshreveable (Ctrl+C to quit)
Session Status online
Session Expires 1 hour, 54 minutes
Version 2.3.35
Region United States (us)
Web Interface http://127.0.0.1:4040
Forwarding http://fb772f2a6437.ngrok.io -> http://localhost:8000
Forwarding https://fb772f2a6437.ngrok.io -> http://localhost:8000
Connections ttl opn rt1 rt5 p50 p90
0 0 0.00 0.00 0.00 0.00
```
Since we are using http use the http link for ngrok in your get and post requests. For the adventrain project specifcally manually pass in the link as a parameter in the get.js file within src/backend as the link only lasts 2 hours and changes everytime.
#### Running the server within Unix VM
We still are working with UConn ITS to make this method work as localhost is not broadcasting outside the network, but all you would need to do is run:
```
node server.js
```
And then similarly to ngrok pass in sdp33.cse.uconn.edu to the host parameter.
#### Running the server fully locally (least preferred)
Clone this git repository on your local machine, connect to pulse secure to connect to the UConn VPN, then in the project directory run:
```
node server.js
```
Then in get.js set host = localhost.
## Potential Issues
### Port in Use
To see if a port is in use run this on 8000
```
sudo netstat -lntp | grep 8000
```
and if there is a port shown then run kill on the PID as shown:
```
sudo kill -9 2173919
```