review env vars and defaults

This commit is contained in:
Smith
2022-08-18 21:20:08 +02:00
parent 8e0792865c
commit 439ce44a5b
9 changed files with 24 additions and 28 deletions

View File

@@ -10,7 +10,7 @@ spec:
scope: RUN_TIME
- key: REFRESH_TIME_MINUTES
scope: RUN_TIME
value: "5"
value: "2"
- key: DISCORD_BOT_TOKEN
scope: RUN_TIME
value: ""

View File

@@ -1,15 +1,15 @@
# Enable debug mode
DBG=0
# Game server info refresh interval in minutes [DEPRECETED]
REFRESH_TIME_MINUTES=5
# Game server info refresh interval in minutes
REFRESH_TIME_MINUTES=2
# Writeable folder for data storage
DATA_PATH=./data/
# Admin secret
SECRET=
SECRET=secret
# Web service host
APP_HOST=localhost
HOST=0.0.0.0
# Web service port
APP_PORT=8080
PORT=8080
# Discord bot token
DISCORD_BOT_TOKEN=
# Telegram bot token

1
.gitignore vendored
View File

@@ -5,7 +5,6 @@ logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

View File

@@ -1 +1 @@
web: node server.js
web: node dist/server.js

View File

@@ -25,7 +25,7 @@ The main goals of this repo:
# Project Status
The code itself is stable and continuously tested/deployed from the cloud branch.
The project is in a very early stage. More detailed customization options and additional features will be added as requested.
The project is in a very early stage. More detailed customization options and features will be added as requested.
### Possible features and configuration options to add in the future
* optional player list
@@ -90,9 +90,10 @@ npm run dev
## Settings
The behaviour of the watcher service can be configured via environmental variables (env vars).
`.env` ([dotenv](https://www.npmjs.com/package/dotenv)) file is also supported, to look at the avaialable values and defaults check the [default.env](./default.env) file.
`.env` ([dotenv](https://www.npmjs.com/package/dotenv)) file is also supported, to look at the avaialable values and defaults check the [.env.example](./.env.example) file.
To get started, you can simply rename the `.env.example` file to `.env`.
Refer to the wiki on how to get tokens for:
Refer to the wiki on how to acquire tokens for:
* [steam](https://github.com/a-sync/game-server-watcher/wiki/Steam-Web-API-key)
* [discord](https://github.com/a-sync/game-server-watcher/wiki/Discord-bot-token)
* [telegram](https://github.com/a-sync/game-server-watcher/wiki/Telegram-bot-token)
@@ -147,8 +148,10 @@ npm i --only=prod
```
_If you can not install dependencies on the host, do a local install and copy the `./node_modules/` folder to the host._
### Configuration
Create a writeable folder for the data storage. (configured by `DATA_PATH` env var, default: `./data/`)
### Service configuration
Create environmental variables to enable the required features and to customize the service.
1. Make sure the service can write to the data storage path. (configured by `DATA_PATH` env var, default: `./data/`)
2. Make sure you create a unique admin secret. (configured by `SECRET` env var, default: `secret`)
### Running
Run the program from the deployment folder:

View File

@@ -10,9 +10,9 @@
"required": true
},
"REFRESH_TIME_MINUTES": {
"description": "Game server info refresh interval in minutes [DEPRECETED]",
"description": "Game server info refresh interval in minutes",
"required": true,
"value": "5"
"value": "2"
},
"DISCORD_BOT_TOKEN": {
"description": "Discord bot token",

View File

@@ -24,11 +24,11 @@
},
"refreshTimeMinutes": {
"type": "int",
"defaultValue": 5,
"defaultValue": 2,
"minValue": 1,
"maxValue": 60,
"metadata": {
"description": "Game server info refresh interval in minutes [DEPRECETED]"
"description": "Game server info refresh interval in minutes"
}
},
"discordBotToken": {
@@ -71,9 +71,7 @@
"sku": "Basic",
"skuCode": "B1",
"linuxFxVersion": "NODE|16-lts",
"hostingPlanName": "[format('AppServicePlan-{0}', parameters('siteName'))]",
"dataPath": "./data/",
"dbg": "",
"hostingPlanName": "[format('AppServicePlan-{0}', parameters('siteName'))]"
},
"resources": [
{
@@ -133,9 +131,7 @@
"REFRESH_TIME_MINUTES": "[parameters('refreshTimeMinutes')]",
"DISCORD_BOT_TOKEN": "[if(equals('-', parameters('discordBotToken')), '', parameters('discordBotToken'))]",
"TELEGRAM_BOT_TOKEN": "[if(equals('-', parameters('telegramBotToken')), '', parameters('telegramBotToken'))]",
"STEAM_WEB_API_KEY": "[if(equals('-', parameters('steamWebApiKey')), '', parameters('steamWebApiKey'))]",
"DATA_PATH": "[variables('dataPath')]",
"DBG": "[variables('dbg')]"
"STEAM_WEB_API_KEY": "[if(equals('-', parameters('steamWebApiKey')), '', parameters('steamWebApiKey'))]"
}
},
{

View File

@@ -1,2 +0,0 @@
"use strict";
require('./dist/server.js');

View File

@@ -8,9 +8,9 @@ import 'dotenv/config';
import { GameServerConfig, main, readConfig, updateConfig } from './watcher';
const CACHE_MAX_AGE = parseInt(process.env.CACHE_MAX_AGE || '0', 10);
const APP_HOST = process.env.app_host || process.env.APP_HOST || '0.0.0.0';
const APP_PORT = parseInt(process.env.PORT || process.env.app_port || process.env.APP_PORT || '8080', 10);
const SECRET = process.env.SECRET || '';
const APP_HOST = process.env.HOST || process.env.APP_HOST || '0.0.0.0';
const APP_PORT = parseInt(process.env.PORT || process.env.APP_PORT || '8080', 10);
const SECRET = process.env.SECRET || 'secret';
const DATA_PATH = process.env.DATA_PATH || './data/';
const DBG = Boolean(process.env.DBG || false);
const FEET_STEAM = Boolean(process.env.STEAM_WEB_API_KEY);