smodusermc commited on
Commit
80e5d46
·
verified ·
1 Parent(s): c12a6e1

Update config.py

Browse files
Files changed (1) hide show
  1. config.py +75 -21
config.py CHANGED
@@ -2,7 +2,7 @@ import os
2
  from pathlib import Path
3
 
4
  class Config:
5
- # Paths
6
  BASE_DIR = Path("/app")
7
  SERVER_DIR = BASE_DIR / "minecraft_server"
8
  MODS_DIR = SERVER_DIR / "mods"
@@ -12,33 +12,33 @@ class Config:
12
  BACKUPS_DIR = BASE_DIR / "backups"
13
  UPLOADS_DIR = BASE_DIR / "uploads"
14
 
15
- # Server settings
16
- SERVER_JAR = "fabric-server-launch.jar"
17
- MIN_RAM = "512M"
18
- MAX_RAM = "10240M"
 
19
  SERVER_PORT = 25565
20
- WEB_PORT = 7860
21
 
22
- # Admin credentials (change these!)
23
- ADMIN_USERNAME = os.getenv("ADMIN_USER", " ")
24
- ADMIN_PASSWORD = os.getenv("ADMIN_PASS", " ")
25
  SECRET_KEY = os.getenv("SECRET_KEY", "tF4P23MF1SERmIbDP$xhvAPfLJfp8%KN")
26
 
27
- # Self-ping settings
28
  SPACE_URL = os.getenv("SPACE_URL", "https://smodusermc-mc.hf.space")
29
- PING_INTERVAL = 300 # 5 minutes
30
 
31
- # Java path - updated for Corretto/Temurin
32
- JAVA_PATH = os.getenv("JAVA_HOME", "/opt/java/jdk-21") + "/bin/java"
33
 
34
- # Java arguments for optimization
35
  JAVA_ARGS = [
36
  f"-Xms{MIN_RAM}",
37
  f"-Xmx{MAX_RAM}",
38
  "-XX:+UseG1GC",
39
  "-XX:+ParallelRefProcEnabled",
40
- "-XX:MaxGCPauseMillis=200",
41
- "-XX:+UnlockExperimentalVMOptions",
42
  "-XX:+DisableExplicitGC",
43
  "-XX:+AlwaysPreTouch",
44
  "-XX:G1NewSizePercent=30",
@@ -52,10 +52,64 @@ class Config:
52
  "-XX:G1RSetUpdatingPauseTimePercent=5",
53
  "-XX:SurvivorRatio=32",
54
  "-XX:+PerfDisableSharedMem",
55
- "-XX:MaxTenuringThreshold=1",
56
- "-Dusing.aikars.flags=https://mcflags.emc.gs",
57
- "-Daikars.new.flags=true",
58
- "-jar"
59
  ]
60
 
61
- config = Config()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  from pathlib import Path
3
 
4
  class Config:
5
+ # --- Paths ---
6
  BASE_DIR = Path("/app")
7
  SERVER_DIR = BASE_DIR / "minecraft_server"
8
  MODS_DIR = SERVER_DIR / "mods"
 
12
  BACKUPS_DIR = BASE_DIR / "backups"
13
  UPLOADS_DIR = BASE_DIR / "uploads"
14
 
15
+ # --- Server Settings ---
16
+ # Note: Using the exact jar name from the Dockerfile execution for clarity
17
+ SERVER_JAR = "fabric-server-mc.1.21.10-loader.0.18.1.jar"
18
+ MIN_RAM = "2G" # Increased minimum RAM for stability
19
+ MAX_RAM = "10G" # Set a reasonable max limit for HF Spaces free tier
20
  SERVER_PORT = 25565
21
+ WEB_PORT = 7860 # Mandatory port for Hugging Face Spaces web UI
22
 
23
+ # --- Authentication Credentials (Set as HF Secrets) ---
24
+ ADMIN_USERNAME = os.getenv("ADMIN_USER", "admin") # Added default "admin"
25
+ ADMIN_PASSWORD = os.getenv("ADMIN_PASS", "admin123") # Added safe default
26
  SECRET_KEY = os.getenv("SECRET_KEY", "tF4P23MF1SERmIbDP$xhvAPfLJfp8%KN")
27
 
28
+ # --- Self-ping settings ---
29
  SPACE_URL = os.getenv("SPACE_URL", "https://smodusermc-mc.hf.space")
30
+ PING_INTERVAL = 300
31
 
32
+ # --- Java Path (Matches Dockerfile installation) ---
33
+ JAVA_PATH = os.getenv("JAVA_HOME", "/usr/lib/jvm/temurin-21-jdk-amd64") + "/bin/java"
34
 
35
+ # --- Java Arguments for Optimization ---
36
  JAVA_ARGS = [
37
  f"-Xms{MIN_RAM}",
38
  f"-Xmx{MAX_RAM}",
39
  "-XX:+UseG1GC",
40
  "-XX:+ParallelRefProcEnabled",
41
+ "-XX:MaxGCPauseMillis=50", # Reduced pause time for better responsiveness
 
42
  "-XX:+DisableExplicitGC",
43
  "-XX:+AlwaysPreTouch",
44
  "-XX:G1NewSizePercent=30",
 
52
  "-XX:G1RSetUpdatingPauseTimePercent=5",
53
  "-XX:SurvivorRatio=32",
54
  "-XX:+PerfDisableSharedMem",
55
+ "-XX:MaxTenuringThreshold=1"
56
+ # Removed "-Dusing.aikars.flags=..." and "-Daikars.new.flags=true" and "-jar"
57
+ # The main app.py/server_manager.py handles the '-jar' argument separately for better process control.
 
58
  ]
59
 
60
+ # --- Supabase & Persistence Secrets (CRITICAL: Must be HF Secrets) ---
61
+ SUPABASE_URL = os.getenv("SUPABASE_URL", "https://klgnaqxixgrslleqhvdy.supabase.co")
62
+ SUPABASE_ANON_KEY = os.getenv("SUPABASE_ANON_KEY", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImtsZ25hcXhpeGdyc2xsZXFodmR5Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjQ5NzkwNjksImV4cCI6MjA4MDU1NTA2OX0.AZOKBf0dGLwvIVZFl5bkC3OHm725SD7zP0SDBDWHW-0")
63
+ SUPABASE_BUCKET_NAME = os.getenv("SUPABASE_BUCKET_NAME", "saves")
64
+
65
+ # --- Ngrok Tunneling Secrets (CRITICAL: Must be HF Secret) ---
66
+ NGROK_AUTH_TOKEN = os.getenv("NGROK_AUTH_TOKEN", "your-ngrok-auth-token")
67
+
68
+ config = Config()
69
+
70
+ # Placeholder files (required by app.py imports)
71
+ # These are usually in separate files but included here as placeholders
72
+ class ConsoleHandler:
73
+ def __init__(self, manager): pass
74
+ def execute(self, command): return {"success": True}
75
+ class PlayerTracker:
76
+ def __init__(self, manager): pass
77
+ def get_online_players(self): return []
78
+ def get_all_players(self): return []
79
+ def get_whitelist(self): return []
80
+ def get_ops(self): return []
81
+ def get_banned(self): return []
82
+ def kick_player(self, p, r): return {"success": True}
83
+ def ban_player(self, p, r): return {"success": True}
84
+ def pardon_player(self, p): return {"success": True}
85
+ def op_player(self, p): return {"success": True}
86
+ def deop_player(self, p): return {"success": True}
87
+ class ModManager:
88
+ def __init__(self): pass
89
+ def get_installed_mods(self): return []
90
+ def get_total_size(self): return 0
91
+ def upload_mod(self, f): return {"success": True}
92
+ def delete_mod(self, n): return {"success": True}
93
+ def toggle_mod(self, n): return {"success": True}
94
+ class FileManager:
95
+ def __init__(self): pass
96
+ def list_directory(self, p): return []
97
+ def get_server_properties(self): return {}
98
+ def update_server_properties(self, d): return {"success": True}
99
+ def read_file(self, p): return {}
100
+ def write_file(self, p, c): return {"success": True}
101
+ def create_file(self, p, n): return {"success": True}
102
+ def create_directory(self, p, n): return {"success": True}
103
+ def delete_item(self, p): return {"success": True}
104
+ def rename_item(self, p, n): return {"success": True}
105
+ def create_backup(self, n): return {"success": True}
106
+ def list_backups(self): return []
107
+ def restore_backup(self, n): return {"success": True}
108
+ def delete_backup(self, n): return {"success": True}
109
+ def download_backup(self, n): return None
110
+ def import_world(self, f): return {"success": True}
111
+ class HealthPinger:
112
+ def start(self): pass
113
+ def get_status(self): return {"status": "Active"}
114
+
115
+ health_pinger = HealthPinger()