Global server and player stats tracking for Cube 2: Sauerbraten.
This is the second iteration of sauertracker.net. It has many improvements over the original Tracker.
Written in ECMAScript 6, the new version of JavaScript, and transpiled to ECMAScript 5 using Babel. nde Powered by NodeJS, Pug (Jade), Sass, PostgreSQL, and Redis.
The build process in this branch is broken. It was migrated from Gulp to Webpack, but the front-end JS could not be ported. A new front-end is being worked on, but in the meantime, this branch provides you with a precompiled set of assets that works.
Node.js (tested on v6.10.3)
PostgreSQL (tested on v9.4.12)
Redis (tested on v4.0.6)
There are 2 configuration files: config.json and vars.json.
config.json contains server-side only options, whereas vars.json is shared between the client and the server.
An example configuration is included in config.default.json. You must rename it to config.json before proceeding.
You will also need an (empty) PostgreSQL database. You can configure the connection URL in config.json.
To learn more, read the configuration file's wiki page.
# Clone the repository
git clone https://github.com/AngrySnout/SauerTracker
cd SauerTracker
# Install the dependencies
npm install
# Build the Tracker
npm run-script build
# Pull the repository
git pull origin master
# Update the dependencies
npm install
# Rebuild the Tracker
npm run-script build
# Start it using forever, so it restarts automatically when it crashes
npm start
# Manually restart it
npm restart
# Or shut it down
npm stop
# Clone the repository
git clone https://github.com/AngrySnout/SauerTracker
cd SauerTracker
# Start SauerTracker
docker-compose up -d
# If you don't have a dump file already, create one using
pg_dump SauerTracker > dump.sql
# Then put this file in the root directory, edit docker-compose.yml and uncomment the line
# - ./dump.sql:/docker-entrypoint-initdb.d/init.sql:ro
# Start only the database
docker-compose up postgres
# Wait for the import to finish then press CTRL+C to shut it down, recomment the line, and
# start SauerTracker
docker-compose up -d
For development it is easier to have Gulp and Knex installed globally. This can be achieved with:
npm install gulp -g
npm install knex -g
Then you simply run
gulp
in the root directory, which watches all files for changes and build them accordingly.
To run the Tracker, run
node index.js
in the root directory.
The Tracker has he following file tree:
- assets * api/v2/schemas - Contains all JSON schemas for API v2. * fonts, images - Static files that don't frequently change. * js - Browser-side transpiled JavaScript files. * styles - CSS style files.
- build - Where all transpiled server-side JavaScript files reside.
- migrations - Database migrations.
- src - The core of the tracker. This directory contains all server-side JavaScript code.
- test - Tests for the src directory.
- website * js - Client-side JavaScript files. * styles - Sass styles. * views - Webite views, written in Pug.
- tracker.default.json - Default configuration file.
- vars.json - Various variables used by the Tracker.
- ...
The Tracker uses Knex for building queries and handling database interaction. If you wish to make changes to the database schema, you have to create a new migration using:
knex migrate:make migration_name
This will create a new file in /migrations, in which you should put all changes to the schema (more about migrations). When you're done run:
knex migrate:latest
You can use ESDoc to generate documentation. The Tracker's documentation is poor, but should give you an overview of some of the functionality. To generate the docs run the following commands:
npm install esdoc -g
esdoc -c esdoc.json
This will create the docs in the /esdoc directory.
What is the point of having Redis as a requirement?
The Tracker uses Redis for persistent cache storage. By delegating caching responsibilities to Redis, restarts and crashes have little effect on the performance of the Tracker.
GNU General Public License v3.0