ThongCoding commited on
Commit
2126d64
verified
1 Parent(s): 578595c

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import subprocess
3
+ import threading
4
+
5
+ def start_backup_service():
6
+ proc = subprocess.Popen(
7
+ ["python3", "/backup.py"],
8
+ stdout=subprocess.PIPE,
9
+ stderr=subprocess.STDOUT,
10
+ text=True,
11
+ bufsize=1
12
+ )
13
+ # Stream logs in real-time
14
+ for line in proc.stdout:
15
+ print("[Backup]", line.strip())
16
+
17
+ print("Starting Restorer.")
18
+ subprocess.run(["python3", "/restore.py"], check=True)
19
+ print("Finished.")
20
+
21
+ print("Starting Auto-Backup Service.")
22
+ thr = threading.Thread(target=start_backup_service, daemon=True)
23
+ thr.start()
24
+
25
+ print("Starting Coder server.")
26
+ subprocess.run([
27
+ "code-server",
28
+ "--bind-addr", "0.0.0.0:7860",
29
+ "--auth", "none",
30
+ "/home/vscode/workspace"
31
+ ])