Tracks and maps RPI's shuttles with Go, Postgres, Vue.js, TypeScript, and Leaflet. Check it out in action at poly.rpi.edu/shuttles.
- Install Go. Shuttle Tracker requires Go 1.11 or newer, and we recommend using the latest stable Go release.
- 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. - Ensure you have Postgres downloaded, installed, and running. On macOS, Homebrew makes this easy.
- Run
createdb shuttletracker
to create a Postgres database. - Switch to the Shuttle Tracker directory (
cd shuttletracker
) - Rename
conf.json.sample
toconf.json
- 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.
- Install Node.js and npm.
- Switch to the
./frontend
directory. - Run
npm install
- 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.
- Note: if you are working on the frontend, you may instead use
- Go back up to the project root directory and build Shuttle Tracker by running
go build -o shuttletracker ./cmd/shuttletracker
- Start the app by running
./shuttletracker
in the project root directory. - Add yourself as an administrator by using
./shuttletracker admins --add RCS_ID
, replacingRCS_ID
with your RCS ID. See the "Administrators" section below for more information. - Visit http://localhost:8080/ to view the tracking application and http://localhost:8080/admin to view the administration panel.
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.
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
.
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
.
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.
> ./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
- Uninstall any older version of Go that may be on your computer. Click here for a guide on uninstalling Go.
- Download Go. Shuttle Tracker targets Go version 1.7 and newer, but we recommend using the latest stable release of Go.
3. Open your System Properties by searching Edit the system environment variables
then press Environment Variables...
.
- Ensure your
GOPATH
variable is set correctly in theUser variables for (Username)
. - Select
Path
underUser variables for (Username)
and make sure%GOPATH%\bin
is on the list. - Make sure
GOROOT
is set correctly underSystem variables
. - Select
Path
underSystem variables
Make sureGOROOT\bin
is on the list.
This step should be done for you already.
4. Open a command prompt by pressing windows + r, then type cmd
and hit ok, or search for command prompt.
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
.
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.
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.
- Navigate to your shuttle tracker directory (
$GOPATH/src/github.com/thepoly/shuttletracker
) and renameconf.json.sample
toconf.json
- 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"
.
- Install Node.js and npm. Download the recommeneded version and install. Restart your command prompt.
- Navigate to the frontend directory within the shuttle tracker directory (
$GOPATH/src/github.com/thepoly/shuttletracker/frontend
). - Run
npm install
- Build the frontend using
npx vue-cli-service build --mode development
- Go back up to the project root directory (using
cd ..
) and build Shuttle Tracker by runninggo build -o shuttletracker.exe cmd/shuttletracker/main.go
- Start the app by running
shuttletracker.exe
in the project root directory. - Add yourself as an administrator by using
shuttletracker.exe admins --add RCS_ID
, replacingRCS_ID
with your RCS ID. See the "Administrators" section below for more information. - Visit http://localhost:8080/ to view the tracking application and http://localhost:8080/admin to view the administration panel.
- Copy the information from vehicles, routes, and stops into the admin panel if you want to mimic the current shuttle tracker site.