4 Commits

4 changed files with 12 additions and 5 deletions

View File

@@ -12,6 +12,7 @@
"type": "module",
"dependencies": {
"@discordjs/voice": "^0.17.0",
"axios": "^1.7.7",
"convert-units": "^2.3.4",
"discord.js": "^14.15.3",
"dotenv": "^16.4.5",

View File

@@ -94,8 +94,8 @@ rm -rf /usr/lib/python3.11/EXTERNALLY-MANAGED
# Getting the Python DAB
echo "Installing PDAB and Dependencies"
git clone -b DRBv3 https://git.vpn.cusano.net/logan/Python-Discord-Audio-Bot.git ./discordAudioBot/pdab
pip3 install -r ./discordAudioBot/pdab/requirements.txt
git clone -b DRBv3 https://git.vpn.cusano.net/logan/Python-Discord-Audio-Bot.git ./pdab
pip3 install -r ./pdab/requirements.txt
# Create a systemd service file for the DRB Client
echo "Adding DRB Node service..."

View File

@@ -25,7 +25,7 @@ let botCallback;
export const initDiscordBotClient = (clientId, callback, runPDAB = true) => {
botCallback = callback;
if (runPDAB) launchProcess("python", [join(__dirname, "./pdab/main.py"), process.env.AUDIO_DEVICE_ID, clientId, port], false, false, join(__dirname, "./pdab"));
if (runPDAB) launchProcess("python", [join(__dirname, "../../pdab/main.py"), process.env.AUDIO_DEVICE_ID, clientId, port], false, false, join(__dirname, "../../pdab"));
pdabProcess = true; // TODO - Make this more dynamic
}

View File

@@ -11,6 +11,9 @@ dotenv.config();
let currentSystem = undefined;
let crashDetectionInterval; // Variable to store the crash detection interval ID
// Sleep utility to add delays between retries
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
/**
* Checks the health of the OP25 web portal by making an HTTP HEAD request.
* If the portal does not respond or there is an issue, retries a specified number of times.
@@ -25,7 +28,7 @@ const checkServiceHealth = async () => {
try {
log.INFO("Checking OP25 web portal health...");
// Perform an HTTP HEAD request to the web portal with a 5-second timeout
await axios.head('http://localhost:8081', { timeout: 5000 });
await axios({ method: "get", url: 'http://localhost:8081', timeout: 5000 });
log.INFO("Web portal is healthy.");
} catch (error) {
if (error.code === 'ECONNABORTED') {
@@ -40,10 +43,13 @@ const checkServiceHealth = async () => {
// Retry mechanism
const retryAttempts = 3;
const delayBetweenRetries = 3000; // 3 seconds delay
for (let i = 1; i <= retryAttempts; i++) {
log.INFO(`Retrying to check web portal health... Attempt ${i}/${retryAttempts}`);
try {
await axios.head('http://localhost:8081', { timeout: 5000 });
await sleep(delayBetweenRetries); // Add delay before retrying
await axios({ method: "get", url: 'http://localhost:8081', timeout: 5000 });
log.INFO("Web portal is healthy on retry.");
return;
} catch (retryError) {