Remove MongoDB; add PM2 scripts, CI, tests; fix PlayerTab hooks; add pm2 smoke-test

This commit is contained in:
2025-08-16 13:01:30 +02:00
parent fe3a57a9c9
commit b6320ceff6
38 changed files with 453 additions and 622 deletions

View File

@@ -1,40 +0,0 @@
const mongoose = require('mongoose');
const Player = require('../database/playerModel');
const GMSession = require('../database/gmSessionModel');
async function setupDatabase() {
try {
console.log('Connecting to MongoDB...');
await mongoose.connect('mongodb://localhost:27017/deathwatch', {
useNewUrlParser: true,
useUnifiedTopology: true,
});
console.log('Connected to MongoDB.');
console.log('Initializing collections...');
// Initialize Players collection
const samplePlayers = [
{ name: 'Player1', rollerInfo: {}, shopInfo: {}, tabInfo: {} },
{ name: 'Player2', rollerInfo: {}, shopInfo: {}, tabInfo: {} },
];
await Player.insertMany(samplePlayers);
console.log('Players collection initialized.');
// Initialize GM Sessions collection
const sampleSessions = [
{ sessionId: 'session1', isActive: true },
{ sessionId: 'session2', isActive: false },
];
await GMSession.insertMany(sampleSessions);
console.log('GM Sessions collection initialized.');
console.log('Database setup completed successfully.');
} catch (error) {
console.error('Error during database setup:', error.message);
} finally {
mongoose.connection.close();
}
}
setupDatabase();

View File

@@ -1,26 +0,0 @@
const { execSync } = require('child_process');
function installMongoDB() {
try {
console.log('Installing gnupg and curl...');
execSync('sudo apt-get install -y gnupg curl', { stdio: 'inherit' });
console.log('Importing MongoDB public GPG key...');
execSync('curl -fsSL https://www.mongodb.org/static/pgp/server-8.0.asc | sudo gpg -o /usr/share/keyrings/mongodb-server-8.0.gpg --dearmor', { stdio: 'inherit' });
console.log('Creating MongoDB list file...');
execSync('echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] https://repo.mongodb.org/apt/ubuntu noble/mongodb-org/8.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-8.0.list', { stdio: 'inherit' });
console.log('Reloading package database...');
execSync('sudo apt-get update', { stdio: 'inherit' });
console.log('Installing MongoDB Community Server...');
execSync('sudo apt-get install -y mongodb-org', { stdio: 'inherit' });
console.log('MongoDB installation completed successfully.');
} catch (error) {
console.error('Error during MongoDB installation:', error.message);
}
}
installMongoDB();