Spaces:
Running
Running
techedstudios commited on
Commit ·
0cc5efc
1
Parent(s): 2b6e271
Feat: Add automatic Paper/Spigot CPU optimizations for HuggingFace environment
Browse files- backend/process-manager.js +21 -0
backend/process-manager.js
CHANGED
|
@@ -177,6 +177,27 @@ export class MCProcessManager {
|
|
| 177 |
if (!isBedrock) {
|
| 178 |
fs.writeFileSync(eulaFile, 'eula=true\n');
|
| 179 |
onLog(serverId, `[SYSTEM] Enforced Minecraft EULA acceptance.`);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 180 |
}
|
| 181 |
|
| 182 |
onStatusChange(serverId, 'starting');
|
|
|
|
| 177 |
if (!isBedrock) {
|
| 178 |
fs.writeFileSync(eulaFile, 'eula=true\n');
|
| 179 |
onLog(serverId, `[SYSTEM] Enforced Minecraft EULA acceptance.`);
|
| 180 |
+
|
| 181 |
+
// Apply HuggingFace CPU Optimizations (as requested by user)
|
| 182 |
+
try {
|
| 183 |
+
const spigotFile = path.join(serverDir, 'spigot.yml');
|
| 184 |
+
if (fs.existsSync(spigotFile)) {
|
| 185 |
+
let spigot = fs.readFileSync(spigotFile, 'utf8');
|
| 186 |
+
spigot = spigot.replace(/nerf-spawner-mobs: false/g, 'nerf-spawner-mobs: true');
|
| 187 |
+
spigot = spigot.replace(/item-despawn-rate: 6000/g, 'item-despawn-rate: 6000\n alt-item-despawn-rate:\n enabled: true\n items:\n cobblestone: 300\n netherrack: 300\n dirt: 300');
|
| 188 |
+
fs.writeFileSync(spigotFile, spigot);
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
+
const paperConfigFile = path.join(serverDir, 'config', 'paper-world-defaults.yml');
|
| 192 |
+
if (fs.existsSync(paperConfigFile)) {
|
| 193 |
+
let paper = fs.readFileSync(paperConfigFile, 'utf8');
|
| 194 |
+
paper = paper.replace(/disable-move-event: false/g, 'disable-move-event: true');
|
| 195 |
+
fs.writeFileSync(paperConfigFile, paper);
|
| 196 |
+
}
|
| 197 |
+
onLog(serverId, `[SYSTEM] Applied advanced CPU/RAM optimizations for HuggingFace environment!`);
|
| 198 |
+
} catch(e) {
|
| 199 |
+
onLog(serverId, `[SYSTEM] Notice: Could not apply auto-optimizations (might apply on next reboot after configs generate).`);
|
| 200 |
+
}
|
| 201 |
}
|
| 202 |
|
| 203 |
onStatusChange(serverId, 'starting');
|