Skip to content

Commit 4f7ee5c

Browse files
committed
Merge branch 'development'
2 parents 9c4f97d + 9a49f9b commit 4f7ee5c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+313
-188
lines changed

ARCHITECTURE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Discord and provides all the commands that you can use. It will always only run
1313
1414
### Instance
1515
Each `Instance` specifies a DCS executable that can be launched on that specific node. The name of the instance matches
16-
your Saved Games directory. The single instance that every server should have is DCS.release_server.
16+
your Saved Games directory. The single instance that every server should have is DCS.dcs_serverrelease.
1717

1818
Each instance has its own UDP communication port (default 6666). It will contact the DCSServerBot via UDP usually
1919
over port 10042. The whole communication is UDP-based. This has a slight risk of data loss, but is non-blocking

MULTINODE.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,15 @@ installation. If not specified otherwise, the node-name will be the hostname of
146146

147147
> [!TIP]
148148
> If you use multiple nodes on multiple PCs, you might get to the moment where instances are named identically.
149-
> This will start with the first instance already if you keep the default name "DCS.release_server".<br>
149+
> This will start with the first instance already if you keep the default name "DCS.dcs_serverrelease".<br>
150150
> As many configuration files only use the instance name per default, you might need to add the node name as well.
151151
> This can be done the same as it is already in your nodes.yaml: The node can be the outer structure in each config file.
152152
>
153153
> Single-Node-Config:
154154
> ```yaml
155155
> DEFAULT:
156156
> some-param: A
157-
> DCS.release_server:
157+
> DCS.dcs_serverrelease:
158158
> some-param: B
159159
> ```
160160
>
@@ -163,15 +163,15 @@ installation. If not specified otherwise, the node-name will be the hostname of
163163
> DEFAULT:
164164
> some-param: A
165165
> MyNode1:
166-
> DCS.release_server:
166+
> DCS.dcs_serverrelease:
167167
> some-param: B
168168
> MyNode2:
169-
> DCS.release_server:
169+
> DCS.dcs_serverrelease:
170170
> some-param: C
171171
> ```
172172
DCSServerBot will understand both versions. The DEFAULT will be used for ALL instances, independent of which node they
173173
are on. If you don't provide a node in a multi-node-system, the bot will read the same parameters for all instances
174-
that are named DCS.release_server on any of your nodes. This can be what you want, but it can lead to errors.<br>
174+
that are named DCS.dcs_serverrelease on any of your nodes. This can be what you want, but it can lead to errors.<br>
175175
I would always recommend creating the node-specific version (ex: "Multi-Node-Config" above) to avoid confusion. That's
176176
what the bot will create during a default installation also.
177177

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,8 @@ NODENAME: # this will usually be your hostname
396396
# Any other Extension:
397397
# ...
398398
instances:
399-
DCS.release_server: # The name of your instance. You can have multiple instances that have to have unique names.
400-
home: '%USERPROFILE%\\Saved Games\\DCS.release_server' # The path to your saved games directory.
399+
DCS.dcs_serverrelease: # The name of your instance. You can have multiple instances that have to have unique names.
400+
home: '%USERPROFILE%\\Saved Games\\DCS.dcs_serverrelease' # The path to your saved games directory.
401401
missions_dir: '%USERPROFILE%\Documents\Missions' # You can overwrite the default missions dir like so. Default is the Missions dir below the instance home folder.
402402
mission_rewrite: false # Disable rewrite of missions by MizEdit or RealWeather. The server will be stopped for any mission change then. (default: true)
403403
bot_port: 6666 # The port DCSServerBot uses to communicate with your DCS server. Each instance has to have a unique port. This is NOT your DCS port (10308)!!!
@@ -408,7 +408,7 @@ NODENAME: # this will usually be your hostname
408408
priority: normal # Optional: set the process priority (low, normal, high, realtime) for the DCS_Server.exe
409409
extensions: # See the extension documentation for more detailed information on what to set here.
410410
SRS:
411-
config: '%USERPROFILE%\Saved Games\DCS.release_server\Config\SRS.cfg' # it is recommended to copy your SRS "server.cfg" below your instances home directory.
411+
config: '%USERPROFILE%\Saved Games\DCS.dcs_serverrelease\Config\SRS.cfg' # it is recommended to copy your SRS "server.cfg" below your instances home directory.
412412
host: 127.0.0.1 # SRS servers local IP (default is 127.0.0.1)
413413
port: 5002 # SRS servers local port (default is 5002). The bot will change this in your SRS configuration if set here!
414414
autostart: true # this will autostart your DCS server with the DCS server start (default: true)

core/data/impl/nodeimpl.py

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ def read_locals(self) -> dict:
265265
if not node:
266266
raise FatalException(f'No configuration found for node {self.name} in {config_file}!')
267267
dirty = False
268+
268269
# check if we need to secure the database URL
269270
database_url = node.get('database', {}).get('url')
270271
if database_url:
@@ -276,6 +277,16 @@ def read_locals(self) -> dict:
276277
f"{url.scheme}://{url.username}:SECRET@{url.hostname}:{port}{url.path}?sslmode=prefer"
277278
dirty = True
278279
self.log.info("Database password found, removing it from config.")
280+
else:
281+
# if we have a cluster.pkl, rename that
282+
cluserdb_pkl = os.path.join(self.config_dir, '.secret', 'clusterdb.pkl')
283+
if os.path.exists(cluserdb_pkl):
284+
database_pkl = os.path.join(self.config_dir, '.secret', 'database.pkl')
285+
# remove existing target to ensure a clean move
286+
if os.path.exists(database_pkl):
287+
os.remove(database_pkl)
288+
os.replace(cluserdb_pkl, database_pkl)
289+
279290
if 'DCS' in node:
280291
password = node['DCS'].pop('dcs_password', node['DCS'].pop('password', None))
281292
if password:
@@ -291,6 +302,33 @@ def read_locals(self) -> dict:
291302
return node
292303
raise FatalException(f"No {config_file} found. Exiting.")
293304

305+
def get_database_urls(self):
306+
cpool_url = self.config.get("database", self.locals.get('database'))['url']
307+
lpool_url = self.locals.get("database", self.config.get('database'))['url']
308+
309+
try:
310+
lpool_pwd = utils.get_password('database', self.config_dir)
311+
except ValueError:
312+
self.log.critical(
313+
"Please replace the SECRET keyword in your database URL with a password!"
314+
)
315+
exit(SHUTDOWN)
316+
317+
if cpool_url != lpool_url:
318+
try:
319+
cpool_pwd = utils.get_password('clusterdb', self.config_dir)
320+
except ValueError:
321+
self.log.critical(
322+
"Please replace the SECRET keyword in your database URL in main.yaml with a password!"
323+
)
324+
exit(SHUTDOWN)
325+
else:
326+
cpool_pwd = lpool_pwd
327+
328+
cpool_url = cpool_url.replace('SECRET', quote(cpool_pwd) or '')
329+
lpool_url = lpool_url.replace('SECRET', quote(lpool_pwd) or '')
330+
return cpool_url, lpool_url
331+
294332
async def init_db(self):
295333
async def check_db(url: str) -> str | None:
296334
max_attempts = self.locals.get("database", self.config.get('database')).get('max_retries', 10)
@@ -308,21 +346,7 @@ async def check_db(url: str) -> str | None:
308346
# we will never be here
309347
return None
310348

311-
cpool_url = self.config.get("database", self.locals.get('database'))['url']
312-
lpool_url = self.locals.get("database", self.config.get('database'))['url']
313-
try:
314-
password = utils.get_password('clusterdb', self.config_dir)
315-
except ValueError:
316-
try:
317-
password = utils.get_password('database', self.config_dir)
318-
utils.set_password('clusterdb', password, self.config_dir)
319-
except ValueError:
320-
self.log.critical("You need to replace the SECRET keyword in your database URL with a proper password!")
321-
exit(SHUTDOWN)
322-
323-
cpool_url = cpool_url.replace('SECRET', quote(password) or '')
324-
lpool_url = lpool_url.replace('SECRET', quote(utils.get_password('database', self.config_dir)) or '')
325-
349+
cpool_url, lpool_url = self.get_database_urls()
326350
version = await check_db(lpool_url)
327351
if lpool_url != cpool_url:
328352
await check_db(cpool_url)
@@ -1026,6 +1050,7 @@ async def check_nodes():
10261050
return True
10271051
# The master is not alive, take over
10281052
elif not master or not await is_node_alive(master, config.get('heartbeat', 30)):
1053+
self.log.warning("The master node is not responding, taking over ...")
10291054
await take_over()
10301055
return True
10311056
# Master is alive, but we are the preferred one

core/utils/validators.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from pathlib import Path
1111
from pykwalify import partial_schemas
1212
from pykwalify.core import Core
13-
from pykwalify.errors import SchemaError, CoreError, PyKwalifyException
13+
from pykwalify.errors import SchemaError, CoreError, PyKwalifyException, UnknownError
1414
from pykwalify.rule import Rule
1515
from typing import Any, Type
1616

@@ -89,15 +89,15 @@ def _initialize(self):
8989
for node, instances in self._instances.items():
9090
for instance in instances:
9191
self._all_instances[instance] = self._all_instances.get(instance, 0) + 1
92-
except Exception:
93-
raise CoreError(msg="nodes.yaml seems to be corrupt, can't initialize the node/instance-validation!")
92+
except Exception as ex:
93+
raise UnknownError(error_key=ex, path='nodes.yaml')
9494

9595
try:
9696
config_path = Path(os.path.join(COMMAND_LINE_ARGS.config, 'servers.yaml'))
9797
data = yaml.load(config_path.read_text(encoding='utf-8'))
9898
self._servers = list(data.keys())
99-
except Exception:
100-
raise CoreError(msg="servers.yaml seems to be corrupt, can't initialize the server-validation!")
99+
except Exception as ex:
100+
raise UnknownError(error_key=ex, path='servers.yaml')
101101

102102
@property
103103
def nodes(self):
@@ -366,9 +366,13 @@ def validate(source_file: str, schema_files: list[str], *, raise_exception: bool
366366
try:
367367
c.validate(raise_exception=True)
368368
except PyKwalifyException as ex:
369+
if ex.error_key:
370+
source_file = ex.error_key
369371
if raise_exception:
370372
raise
371373
if isinstance(ex, SchemaError):
372374
logger.warning(f'Error while parsing {source_file}:\n{ex}')
375+
elif isinstance(ex, UnknownError):
376+
logger.error(f'Error while parsing {ex.path}:\n{ex.error_key}')
373377
else:
374378
logger.error(f'Error while parsing {source_file}:\n{ex}', exc_info=ex)

extensions/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ MyNode:
6161
param2: bb
6262
# [...]
6363
instances:
64-
DCS.release_server:
64+
DCS.dcs_serverrelease:
6565
# [...]
6666
extensions:
6767
mymodule.MyExtension:

extensions/dsmc/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ extension like with all others:
1111
MyNode:
1212
# [...]
1313
instances:
14-
DCS.release_server:
14+
DCS.dcs_serverrelease:
1515
# [...]
1616
extensions:
1717
DSMC:

extensions/github/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ To enable track file upload, a change in nodes.yaml is needed:
77
MyNode:
88
# [...]
99
instances:
10-
DCS.release_server:
10+
DCS.dcs_serverrelease:
1111
# [...]
1212
extensions:
1313
GitHub:

extensions/grpc/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ extension:
1010
MyNode:
1111
# [...]
1212
instances:
13-
DCS.release_server:
13+
DCS.dcs_serverrelease:
1414
# [...]
1515
extensions:
1616
gRPC:

extensions/lardoon/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ MyNode:
1717
use_single_process: true # Start one Lardoon process instead of one per node (default: true)
1818
# [...]
1919
instances:
20-
DCS.release_server:
20+
DCS.dcs_serverrelease:
2121
# [...]
2222
extensions:
2323
Lardoon:

0 commit comments

Comments
 (0)