Compare commits

..

11 Commits

Author SHA1 Message Date
Lee
41c28168e9 Update README.md
All checks were successful
Publish Docker Image / docker (push) Successful in 3m48s
2023-12-31 01:09:07 +00:00
565b533ad4 format peak time frame properly
Some checks failed
Publish Docker Image / docker (push) Has been cancelled
2023-12-31 01:07:32 +00:00
5c5e44ad20 fix db location
All checks were successful
Publish Docker Image / docker (push) Successful in 5m6s
2023-12-31 00:13:39 +00:00
f9a9a37e1a add embed
All checks were successful
Publish Docker Image / docker (push) Successful in 4m2s
2023-12-31 00:00:23 +00:00
0fbea0cb4e update default connection timeout 2023-12-30 23:54:53 +00:00
2992ad84da remove ignore (temp)
All checks were successful
Publish Docker Image / docker (push) Successful in 5m16s
2023-12-30 23:32:53 +00:00
f9c7c90d44 e 2023-12-30 23:32:24 +00:00
cc0c0f2368 fix fr 2023-12-30 23:27:22 +00:00
1d4dd08fc6 fix angry (eslint)
Some checks failed
Publish Docker Image / docker (push) Failing after 2m1s
2023-12-30 23:23:56 +00:00
0d03516d04 remove schedule
Some checks failed
Publish Docker Image / docker (push) Failing after 3m19s
2023-12-30 23:15:10 +00:00
4bce544d98 add workflow to build image
Some checks are pending
Publish Docker Image / docker (push) Waiting to run
2023-12-30 23:14:59 +00:00
12 changed files with 103 additions and 48 deletions

@ -1,5 +1,3 @@
{ {
"plugins": [ "plugins": ["@babel/plugin-proposal-class-properties"]
"@babel/plugin-proposal-class-properties"
]
} }

@ -1,19 +1,3 @@
{ {
"env": {
"browser": true,
"es6": true
},
"extends": [
"standard"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaVersion": 2018
},
"rules": {
},
"parser": "babel-eslint" "parser": "babel-eslint"
} }

@ -0,0 +1,43 @@
name: Publish Docker Image
on:
push:
branches:
- "main"
jobs:
docker:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Restore Docker Cache
uses: actions/cache@v3
id: docker-cache
with:
path: /usr/bin/docker
key: ${{ runner.os }}-docker
- name: Install Docker (if not cached)
if: steps.docker-cache.outputs.cache-hit != 'true'
run: |
wget -q -O /tmp/docker.tgz https://download.docker.com/linux/static/stable/x86_64/docker-20.10.23.tgz \
&& tar --extract --file /tmp/docker.tgz --directory /usr/bin --strip-components 1 --no-same-owner docker/docker \
&& rm -rf /tmp/* &&
echo "Done"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Repo
uses: docker/login-action@v2
with:
username: ${{ secrets.REPO_USERNAME }}
password: ${{ secrets.REPO_TOKEN }}
- name: Build and Push
uses: docker/build-push-action@v4
with:
push: true
tags: fascinated/minetrack:latest

@ -4,7 +4,7 @@
# Minetrack # Minetrack
Minetrack makes it easy to keep an eye on your favorite Minecraft servers. Simple and hackable, Minetrack easily runs on any hardware. Use it for monitoring, analytics, or just for fun. [Check it out](https://minetrack.me). Minetrack makes it easy to keep an eye on your favorite Minecraft servers. Simple and hackable, Minetrack easily runs on any hardware. Use it for monitoring, analytics, or just for fun. [Check it out](https://mc.fascinated.cc/).
### This project is not actively supported ### This project is not actively supported
@ -51,7 +51,7 @@ Minetrack can be built and run with Docker from this repository in several ways:
### Build and deploy directly with Docker ### Build and deploy directly with Docker
``` ```bash
# build image with name minetrack and tag latest # build image with name minetrack and tag latest
docker build . --tag minetrack:latest docker build . --tag minetrack:latest
@ -67,7 +67,7 @@ The published port can be changed by modifying the parameter argument, e.g.:
### Build and deploy with docker-compose ### Build and deploy with docker-compose
``` ```bash
# build and start service # build and start service
docker-compose up --build docker-compose up --build
@ -79,7 +79,7 @@ docker-compose down
The following configuration enables Nginx to act as reverse proxy for a Minetrack instance that is available at port 8080 on localhost: The following configuration enables Nginx to act as reverse proxy for a Minetrack instance that is available at port 8080 on localhost:
``` ```nginx
server { server {
server_name minetrack.example.net; server_name minetrack.example.net;
listen 80; listen 80;

@ -2,8 +2,18 @@
<html> <html>
<head> <head>
<link rel="stylesheet" href="../css/main.css" /> <title>Minetrack</title>
<meta charset="UTF-8" />
<!-- Discord Embed -->
<meta content="Minetrack" property="og:title" />
<meta
content="Tracking minecraft servers since 2023"
property="og:description"
/>
<meta content="https://mc.fascinated.cc/" property="og:url" />
<link rel="stylesheet" href="../css/main.css" />
<link <link
rel="stylesheet" rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;700&display=swap" href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;700&display=swap"
@ -11,11 +21,7 @@
<link rel="icon" type="image/svg+xml" href="../images/logo.svg" /> <link rel="icon" type="image/svg+xml" href="../images/logo.svg" />
<meta charset="UTF-8" />
<script defer type="module" src="../js/main.js"></script> <script defer type="module" src="../js/main.js"></script>
<title>Minetrack</title>
</head> </head>
<body> <body>

@ -4,8 +4,8 @@
"ip": "0.0.0.0" "ip": "0.0.0.0"
}, },
"rates": { "rates": {
"pingAll": 15000, "pingAll": 30000,
"connectTimeout": 2500 "connectTimeout": 5000
}, },
"oldPingsCleanup": { "oldPingsCleanup": {
"enabled": false, "enabled": false,
@ -13,6 +13,6 @@
}, },
"logFailedPings": true, "logFailedPings": true,
"logToDatabase": true, "logToDatabase": true,
"graphDuration": 86400000, "graphDuration": 604800000,
"serverGraphDuration": 180000 "serverGraphDuration": 360000
} }

@ -2,17 +2,19 @@ version: "3"
services: services:
minetrack: minetrack:
build: https://git.fascinated.cc/Fascinated/Minetrack.git image: fascinated/minetrack:latest
# or
# build: https://git.fascinated.cc/Fascinated/Minetrack.git
container_name: minetrack container_name: minetrack
dns: dns:
- 8.8.8.8 - 8.8.8.8
- 1.1.1.1 - 1.1.1.1
ports: ports:
- "8080:8080" - "8880:8080"
volumes: volumes:
# Copy these from the git repo # Copy these from the git repo
- ./servers.json:/usr/src/minetrack/servers.json - ./servers.json:/usr/src/minetrack/servers.json
- ./config.json:/usr/src/minetrack/config.json - ./config.json:/usr/src/minetrack/config.json
- ./data:/data # The sqlite database will be stored here - ./data:/usr/src/minetrack/data # The sqlite database will be stored here
restart: always restart: always

@ -6,6 +6,7 @@ const MessageOf = require("./message");
const config = require("../config"); const config = require("../config");
const minecraftVersions = require("../minecraft_versions"); const minecraftVersions = require("../minecraft_versions");
const { formatMsToTime } = require("./utils/timeUtils");
class App { class App {
serverRegistrations = []; serverRegistrations = [];
@ -74,9 +75,11 @@ class App {
// Send configuration data for rendering the page // Send configuration data for rendering the page
return { return {
// graphDurationLabel:
// config.graphDurationLabel ||
// Math.floor(config.graphDuration / (60 * 60 * 1000)) + "h",
graphDurationLabel: graphDurationLabel:
config.graphDurationLabel || config.graphDurationLabel || formatMsToTime(config.graphDuration),
Math.floor(config.graphDuration / (60 * 60 * 1000)) + "h",
graphMaxLength: TimeTracker.getMaxGraphDataLength(), graphMaxLength: TimeTracker.getMaxGraphDataLength(),
serverGraphMaxLength: TimeTracker.getMaxServerGraphDataLength(), serverGraphMaxLength: TimeTracker.getMaxServerGraphDataLength(),
servers: this.serverRegistrations.map((serverRegistration) => servers: this.serverRegistrations.map((serverRegistration) =>

@ -239,7 +239,6 @@ class Database {
// Record not found // Record not found
if (data[0] === undefined) { if (data[0] === undefined) {
// eslint-disable-next-line node/no-callback-literal
callback(false); callback(false);
return; return;
} }
@ -248,7 +247,6 @@ class Database {
const timestamp = data[0].timestamp; const timestamp = data[0].timestamp;
// Allow null player counts and timestamps, the frontend will safely handle them // Allow null player counts and timestamps, the frontend will safely handle them
// eslint-disable-next-line node/no-callback-literal
callback(true, playerCount, timestamp); callback(true, playerCount, timestamp);
} }
); );
@ -272,10 +270,8 @@ class Database {
// Allow null timestamps, the frontend will safely handle them // Allow null timestamps, the frontend will safely handle them
// This allows insertion of free standing records without a known timestamp // This allows insertion of free standing records without a known timestamp
if (playerCount !== null) { if (playerCount !== null) {
// eslint-disable-next-line node/no-callback-literal
callback(true, playerCount, timestamp); callback(true, playerCount, timestamp);
} else { } else {
// eslint-disable-next-line node/no-callback-literal
callback(false); callback(false);
} }
} }

@ -106,6 +106,7 @@ class PingController {
schedule() { schedule() {
setInterval(this.pingAll, config.rates.pingAll); setInterval(this.pingAll, config.rates.pingAll);
// todo: make this a cron job?
this.pingAll(); this.pingAll();
} }

28
lib/utils/timeUtils.js Normal file

@ -0,0 +1,28 @@
/**
* Formats a time in milliseconds to a human readable format
* eg: 1000ms -> 1s or 60000ms -> 1m
*
* @param ms the time in milliseconds
* @returns the formatted time
*/
function formatMsToTime(ms) {
// this is really fucking shitty but it works!
const seconds = Math.floor(ms / 1000);
const minutes = Math.floor(seconds / 60);
const hours = Math.floor(minutes / 60);
const days = Math.floor(hours / 24);
if (days > 0) {
return `${days}d`;
} else if (hours > 0) {
return `${hours}h`;
} else if (minutes > 0) {
return `${minutes}m`;
} else {
return `${seconds}s`;
}
}
module.exports = {
formatMsToTime,
};

@ -1,6 +0,0 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"local>Fascinated/renovate-config"
]
}