mc-cluster/mc-cluster-image/connection_manager.js
2024-12-06 05:52:08 -05:00

25 lines
804 B
JavaScript

#!/usr/bin/node
const { execSync } = require('child_process');
const port = 25565; // Fixed port
const connectionString = process.env.CONNECTION_STRING;
if (!connectionString) {
console.error("Error: CONNECTION_STRING environment variable is not set.");
process.exit(1);
}
console.log(`Starting connection with the following details:`);
console.log(`Port: ${port}`);
console.log(`Connection String: ${connectionString}`);
// Start the connection using PM2
const pm2cmd = `pm2 start holesail --name holesail_connection -- --live ${port} --connector "${connectionString}"`;
try {
execSync(pm2cmd, { stdio: 'inherit' });
console.log(`Connection started successfully on port ${port} using PM2.`);
} catch (err) {
console.error(`Error starting connection: ${err.message}`);
process.exit(1);
}