ThongCoder commited on
Commit
bcdd725
·
verified ·
1 Parent(s): 8839352

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -9
app.py CHANGED
@@ -1,16 +1,31 @@
1
- import os, subprocess, threading
 
 
2
 
3
  def start_backup_service():
4
- proc = subprocess.run(['python3', '/backup.py'])
5
- for item in proc.stdout: print(item)
 
 
 
 
 
 
 
 
6
 
7
- print('Starting Restorer.')
8
- subprocess.run(['python3', '/restore.py'])
9
- print('Finished.')
10
 
11
- print('Starting Auto-Backup Service.')
12
  thr = threading.Thread(target=start_backup_service, daemon=True)
13
  thr.start()
14
 
15
- print('Starting Coder server.')
16
- subprocess.run(['code-server', '--bind-addr', '0.0.0.0:7860', '--auth', 'none', '/home/vscode/workspace'])
 
 
 
 
 
 
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
+ ])