Spaces:
Paused
Paused
Delete entrypoint.py
Browse files- entrypoint.py +0 -42
entrypoint.py
DELETED
|
@@ -1,42 +0,0 @@
|
|
| 1 |
-
import subprocess, threading, os
|
| 2 |
-
from autobackup import schedule_backups
|
| 3 |
-
from restore import restore_workspace
|
| 4 |
-
|
| 5 |
-
password = os.environ.get("VSCODE_PASS", "changeme")
|
| 6 |
-
|
| 7 |
-
# Ensure correct home/config/data dirs
|
| 8 |
-
home = "/home/coder"
|
| 9 |
-
os.makedirs(f"{home}/.config/code-server", exist_ok=True)
|
| 10 |
-
os.makedirs(f"{home}/.local/share/code-server", exist_ok=True)
|
| 11 |
-
os.makedirs(f"{home}/.cache", exist_ok=True)
|
| 12 |
-
|
| 13 |
-
# First restore
|
| 14 |
-
try:
|
| 15 |
-
restore_workspace()
|
| 16 |
-
except Exception as e:
|
| 17 |
-
print("[WARN] Restore failed:", e)
|
| 18 |
-
|
| 19 |
-
# Start auto-backup thread
|
| 20 |
-
threading.Thread(target=schedule_backups, daemon=True).start()
|
| 21 |
-
|
| 22 |
-
# Write config.yaml
|
| 23 |
-
os.environ['PASSWORD'] = password
|
| 24 |
-
# Prepare environment
|
| 25 |
-
env = os.environ.copy()
|
| 26 |
-
env["HOME"] = home
|
| 27 |
-
env["XDG_CONFIG_HOME"] = f"{home}/.config"
|
| 28 |
-
env["XDG_DATA_HOME"] = f"{home}/.local/share"
|
| 29 |
-
env["XDG_CACHE_HOME"] = f"{home}/.cache"
|
| 30 |
-
|
| 31 |
-
# Run code-server with explicit config + data dirs
|
| 32 |
-
cmd = [
|
| 33 |
-
"code-server",
|
| 34 |
-
"--bind-addr", "0.0.0.0:7860",
|
| 35 |
-
"--auth", "password",
|
| 36 |
-
"--user-data-dir", f"{home}/.local/share/code-server",
|
| 37 |
-
"/workspace"
|
| 38 |
-
]
|
| 39 |
-
|
| 40 |
-
def start_code():
|
| 41 |
-
subprocess.run(cmd, env=env)
|
| 42 |
-
threading.Thread(target=start_code, daemon=True).start()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|