Skip to content

thepoly/shuttletracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Shuttle Tracker Build Status codecov GoDoc

Tracks and maps RPI's shuttles with Go, Postgres, Vue.js, TypeScript, and Leaflet. Check it out in action at poly.rpi.edu/shuttles.

Setting up

  1. Install Go. Shuttle Tracker requires Go 1.11 or newer, and we recommend using the latest stable Go release.
  2. Clone the repository to your computer. On macOS, Linux, or WSL, this can be done with git clone git@github.com:thepoly/shuttletracker.git. If you receive a "permission denied" error, ensure you have added your SSH key to your GitHub account.
  3. Ensure you have Postgres downloaded, installed, and running. On macOS, Homebrew makes this easy.
  4. Run createdb shuttletracker to create a Postgres database.
  5. Switch to the Shuttle Tracker directory (cd shuttletracker)
  6. Rename conf.json.sample to conf.json
  7. Edit conf.json with the following, if necessary:
    • API.MapboxAPIKey: Necessary for creating routes through the admin interface. Create your own token or ask a Shuttle Tracker developer to provide you with one.
    • Postgres.URL: URL where Postgres is located. The provided default typically won't need to be modified.
  8. Install Node.js and npm.
  9. Switch to the ./frontend directory.
  10. Run npm install
  11. Build the frontend using npx vue-cli-service build --mode development
    • Note: if you are working on the frontend, you may instead use npx vue-cli-service build --mode development --watch in another terminal to continuously watch for changes and rebuild.
  12. Go back up to the project root directory and build Shuttle Tracker by running go build -o shuttletracker ./cmd/shuttletracker
  13. Start the app by running ./shuttletracker in the project root directory.
  14. Add yourself as an administrator by using ./shuttletracker admins --add RCS_ID, replacing RCS_ID with your RCS ID. See the "Administrators" section below for more information.
  15. Visit http://localhost:8080/ to view the tracking application and http://localhost:8080/admin to view the administration panel.

Configuration

Shuttle Tracker needs configuration to run properly. The preferred method during development is to create a conf.json file. See conf.json.sample for an example of what it should contain.

Updater.DataFeed: API with tracking information from iTrak. For RPI, this is a unique API URL that we can get data from. It's private, and a Shuttle Tracker developer can provide it to you if necessary. However, by default, Shuttle Tracker will reach out to the instance running at shuttles.rpi.edu to piggyback off of its data feed. This means that most developers will not have to configure this key.

Environment variables

Most keys can be overridden with environment variables. The variables names usually take the format PACKAGE_KEY. For example, overriding the iTRAK updater's update interval could be done with a variable named UPDATER_UPDATEINTERVAL.

Database URL

The database URL is a special case. Following the above convention, it can be set with POSTGRES_URL. However, for ease of deployment on Dokku, it can also be set with DATABASE_URL.

Administrators

The admin interface (at /admin) is only accessible to users who have been added as administrators. There is a command-line utility to do this: shuttletracker admins. It has two flags: --add RCS_ID and --remove RCS_ID. Replace RCS_ID with a valid RCS ID.

Example usage

> ./shuttletracker admins
No Shuttle Tracker administrators.
> ./shuttletracker admins --add kochms
Added kochms.
> ./shuttletracker admins --add lyonj4
Added lyonj4.
> ./shuttletracker admins
kochms
lyonj4
> ./shuttletracker admins --remove lyonj4
Removed lyonj4.
> ./shuttletracker admins
kochms

Setting up (Windows)

  1. Uninstall any older version of Go that may be on your computer. Click here for a guide on uninstalling Go.
  2. Download Go. Shuttle Tracker targets Go version 1.7 and newer, but we recommend using the latest stable release of Go.

Step 2
3. Open your System Properties by searching Edit the system environment variables then press Environment Variables....

  • Ensure your GOPATH variable is set correctly in the User variables for (Username).
  • Select Path under User variables for (Username) and make sure %GOPATH%\bin is on the list.
  • Make sure GOROOT is set correctly under System variables.
  • Select Path under System variables Make sure GOROOT\bin is on the list.

This step should be done for you already.

Step 3
Step 3b
Step 3c
Step 3d
4. Open a command prompt by pressing windows + r, then type cmd and hit ok, or search for command prompt.

Step 4
5. Run go get github.com/thepoly/shuttletracker.
6. Install govendor by running go get -u github.com/kardianos/govendor.
7. Switch to the Shuttle Tracker directory ($GOPATH/src/github.com/thepoly/shuttletracker).
8. Run govendor sync.
Steps 5-8 9. Download and run the installer PostgreSQL from here. Select the latest version. When prompted to set a password, make it something simple, as you will be using this later, for example shuttle. Use default options for everything else. Write down your password.
Step 9
Step 9b
Step 9c
10. When complete, open pgAdmin from your search bar. If you do not see pgAdmin restart your computer. In the Object Browser, open Servers, then open your PostgreSQL server. You will need to enter your password from step 8. Once this is done, right click on Databases and select New Database. Name it shuttletracker and hit Ok.

Step 10
Step 10b
Step 10c

  1. Navigate to your shuttle tracker directory ($GOPATH/src/github.com/thepoly/shuttletracker) and rename conf.json.sample to conf.json
  2. Edit conf.json with the following, if necessary:
  • API.MapboxAPIKey: Necessary for creating routes through the admin interface. Create your own token or ask a Shuttle Tracker developer to provide you with one.
  • Postgres.URL: URL where Postgres is located which will be the default with postgres:password@localhost added before the database name, where password is your password from step 8. For example: "URL": "postgres://postgres:shuttle@localhost/shuttletracker?sslmode=disable".

Step 12

  1. Install Node.js and npm. Download the recommeneded version and install. Restart your command prompt.
    Step 13
    Step 13b
  2. Navigate to the frontend directory within the shuttle tracker directory ($GOPATH/src/github.com/thepoly/shuttletracker/frontend).
  3. Run npm install
    Step 14+15
  4. Build the frontend using npx vue-cli-service build --mode development
    • Note: if you are working on the frontend, you may instead use npx vue-cli-service build --mode development --watch in another terminal to continuously watch for changes and rebuild.
      Step 16
  5. Go back up to the project root directory (using cd ..) and build Shuttle Tracker by running go build -o shuttletracker.exe cmd/shuttletracker/main.go
    Step 17
  6. Start the app by running shuttletracker.exe in the project root directory.
  7. Add yourself as an administrator by using shuttletracker.exe admins --add RCS_ID, replacing RCS_ID with your RCS ID. See the "Administrators" section below for more information.
  8. Visit http://localhost:8080/ to view the tracking application and http://localhost:8080/admin to view the administration panel.
  9. Copy the information from vehicles, routes, and stops into the admin panel if you want to mimic the current shuttle tracker site.