Closed Darkblas closed 1 year ago
They work for me :)
Closing as stale for now.
Hello,
How to work ? Whats is the config/setting necessary ? I need use multiple config.json ? Or in config.json duplicate "port" and "IP" etc ?? Or juste sperate by comma ?
Thanks in advance
I haven't used it since a few years and a lot of things might've changed. Judging by the code, you can't have multiple config files. What you can have is different installations ( copy the same folder as many times as you need and just change the config file as needed).
Side note: In order to reduce data footprint, it could be theoretically possible to provide multiple config files by making a change of the code in index.js
if(Object.keys(argv).length > 2) {
config = argv;
console.log("********\nWARNING: Configuring the bot with arguments is no-longer supported and may not work correctly. Please consider using config.json instead.\nThe arguments must be removed from run.bat/run.sh in order for the config file to take effect.\n********");
}
else {
To:
if(Object.keys(argv).length > 2) {
config = argv;
console.log("********\nWARNING: Configuring the bot with arguments is no-longer supported and may not work correctly. Please consider using config.json instead.\nThe arguments must be removed from run.bat/run.sh in order for the config file to take effect.\n********");
} else if (Object.keys(argv).length == 1) {
configFileName = argv[0];
config = require(`./${configFileName}.json`);
}
else {
Or with more refactoring that allow using .env files: Steps:
_comment2=If arguments are used in run.bat/run.sh, this config file will be ignored.
_comment3=See README.md for the config documentation.
password=changeme token=your_token_here channel=channelid port=8081 ip=localhost
allow-exec-command=false allow-links-from-game=false allow-multiple-instances=false disable-commands=false disable-chatmsgs=false disable-join-leave-gmsgs=false disable-misc-gmsgs=false disable-non-player-chatmsgs=true show-private-chat=false disable-status-updates=false disable-version-check=false hide-prefix=false horde-frequency=7 log-console=false log-messages=false log-telnet=false prefix=7d!
2. Populate it as desired
3. Modify the install script (for example, install.bat) to also include: ```npm install dotenv```
4. Modify the index.js to also allow .env
Replace:
if(Object.keys(argv).length > 2) { config = argv; console.log("****\nWARNING: Configuring the bot with arguments is no-longer supported and may not work correctly. Please consider using config.json instead.\nThe arguments must be removed from run.bat/run.sh in order for the config file to take effect.\n****"); } else {
With:
const dotenv = require('dotenv');
if(Object.keys(argv).length > 2) {
config = argv;
console.log("****\nWARNING: Configuring the bot with arguments is no-longer supported and may not work correctly. Please consider using config.json instead.\nThe arguments must be removed from run.bat/run.sh in order for the config file to take effect.\n****");
} else if (process.env.NODE_ENV) {
dotenv.config({ path: .env.${process.env.NODE_ENV}
});
config = process.env
}
else {
Or something along those lines, haven't tested it.
5. In your node.bat (or whatever you run), replace:
```node index.js```
with
```NODE_ENV=myServer node index.js```
This way, if you need another server, all you need to do is just add another config and modify the runner with your new server. Let's say you make another config named .env.myServer1337, then you would duplicate/modify the runner like so:
```NODE_ENV=myServer1337 node index.js```
This also allows you to set the environment name as environment variable in a potential pipeline or docker-compose variable and it will be automatically overwritten without extra modifications like providing it in the command line.
Again, this is high level, I didn't test it.
- Edit: made some changes to the first example.
@thomasbonsirven @cryptton2004 You should be able to do something similar to this without any code changes using the --configFile
command argument. Simply add --configFile="./config_myAwesomeServer.json"
run.sh example:
#!/bin/sh
until node index.js --configFile="./config_myAwesomeServer.json"; do
echo "Application closed with exit code $?. Restarting in 5s, press Ctrl+C to cancel." >&2
sleep 5
done
read -p "Press enter to continue"
run.bat example:
@ECHO OFF
node index.js --configFile="./config_myAwesomeServer.json"
:loop
echo The bot will restart in 5 seconds. Press N to cancel.
choice /t 5 /c yn /cs /d y /m "Start bot Y/N?"
if errorlevel 3 goto :yes
if errorlevel 2 goto :no
if errorlevel 1 goto :yes
:yes
node index.js
GOTO :loop
:no
pause
Multiple instance not functioning even after changing Telenet port making separate bots ect left with Error connection game closed