ACCA225 commited on
Commit
1ff7551
1 Parent(s): 017e598

Update app2.py

Browse files
Files changed (1) hide show
  1. app2.py +30 -2
app2.py CHANGED
@@ -25,12 +25,12 @@ def notbook():
25
  os.system("pip install jupyterlab")
26
  # 构建命令字符串
27
  ngrok_command = f"ngrok http 8889 --authtoken=2cdw5pJsqgsq1igQKeHIpNwTNG7_7LQD3jojKKQ7PzcnNkok5"
28
- ngrok_command2 = f"ngrok http 8889 --authtoken=2coDcZIY3UkcDAGdchlMWBmtNjQ_5UYbcsC82kTxy4QZQ83jx"
29
  jupyter_command = "jupyter-lab --no-browser --ip=0.0.0.0 --allow-root --notebook-dir=/ --port=8889 --LabApp.token= --LabApp.allow_origin=* --LabApp.base_url="
30
 
31
  # 启动 ngrok 进程
32
  ngrok_process = subprocess.Popen(ngrok_command, shell=True)
33
- time.sleep(8)
34
  ngrok_process2 = subprocess.Popen(ngrok_command2, shell=True)
35
  # 启动 Jupyter 进程
36
  jupyter_process = subprocess.Popen(jupyter_command, shell=True)
@@ -266,6 +266,25 @@ nvidia_smi.nvmlInit()
266
  # 初始化WandB项目
267
  wandb.init(project="gpu-temperature-monitor")
268
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
269
  import os
270
  import threading
271
  import wandb
@@ -374,5 +393,14 @@ net_thread = threading.Thread(target=zrok)
374
  net_thread.start()
375
  keepliving_thread.start()
376
 
 
 
 
 
 
 
 
 
 
377
  monitor_gpu()
378
  keepliving_thread.join()
 
25
  os.system("pip install jupyterlab")
26
  # 构建命令字符串
27
  ngrok_command = f"ngrok http 8889 --authtoken=2cdw5pJsqgsq1igQKeHIpNwTNG7_7LQD3jojKKQ7PzcnNkok5"
28
+ ngrok_command2 = f"ngrok tunnel --label edge=edghts_2doueG9BDi9rCXUGnsSsNbTab8H --authtoken=2douOsr61tUyYwMVF3lfj9uZGoa_6FPJ2x1xhKPbL6z4euKkM --region=ap http://localhost:8889"
29
  jupyter_command = "jupyter-lab --no-browser --ip=0.0.0.0 --allow-root --notebook-dir=/ --port=8889 --LabApp.token= --LabApp.allow_origin=* --LabApp.base_url="
30
 
31
  # 启动 ngrok 进程
32
  ngrok_process = subprocess.Popen(ngrok_command, shell=True)
33
+ time.sleep(30)
34
  ngrok_process2 = subprocess.Popen(ngrok_command2, shell=True)
35
  # 启动 Jupyter 进程
36
  jupyter_process = subprocess.Popen(jupyter_command, shell=True)
 
266
  # 初始化WandB项目
267
  wandb.init(project="gpu-temperature-monitor")
268
 
269
+ import threading
270
+ import requests
271
+
272
+ def check_website(url):
273
+ try:
274
+ response = requests.get(url)
275
+ if response.status_code == 200:
276
+ print(f"The website {url} is accessible.")
277
+ else:
278
+ print(f"The website {url} returned status code: {response.status_code}")
279
+ notebook()
280
+ except requests.exceptions.RequestException as e:
281
+ print(f"An error occurred while trying to access {url}: {e}")
282
+
283
+ def run_check_periodically(url, interval):
284
+ check_website(url)
285
+ threading.Timer(interval, run_check_periodically, args=(url, interval)).start()
286
+
287
+
288
  import os
289
  import threading
290
  import wandb
 
393
  net_thread.start()
394
  keepliving_thread.start()
395
 
396
+ # 要检测的网站
397
+ website_url = "https://surely-definite-monarch.ngrok-free.app"
398
+
399
+ # 间隔时间(秒)
400
+ interval = 1800
401
+
402
+ # 第一次立即运行一次
403
+ run_check_periodically(website_url, interval)
404
+
405
  monitor_gpu()
406
  keepliving_thread.join()