Qilan2 commited on
Commit
195fde1
·
verified ·
1 Parent(s): 3b6690d

Update server.py

Browse files
Files changed (1) hide show
  1. server.py +53 -36
server.py CHANGED
@@ -25,7 +25,7 @@ configs = [
25
  [saffg]
26
  type = tcp
27
  local_ip = 127.0.0.1
28
- local_port = 3000
29
  remote_port = 7071
30
  """, '/content/frp/frpc.ini'),
31
 
@@ -36,34 +36,34 @@ configs = [
36
 
37
  [safg541211ha]
38
  type=tcp
39
- local_ip=127 .0 .0 .1
40
  local_port=8000
41
  remote_port=7070
42
- """, '/content/frp/frpc2.ini'),
43
-
44
- ("""
45
- [common]
46
- server_addr=47.93.130.208
47
- server_port=7000
48
-
49
- [sa211lkk1ha]
50
- type=tcp
51
- local_ip=127 .0 .0 .1
52
- local_port=8000
53
- remote_port=7070
54
- """, '/content/frp/frpc3.ini'),
55
-
56
- ("""
57
- [common]
58
- server_addr=175.178.165.186
59
- server_port=7000
60
-
61
- [safg11ha]
62
- type=tcp
63
- local_ip=127 .0 .0 .1
64
- local_port=80000
65
- remote port=70700
66
- """, '/content/frp/frpc4.ini')
67
  ]
68
  kaggle_metadata = {
69
  "title": "Your Dataset Title",
@@ -335,12 +335,27 @@ def copy_public_key_to_remote(host, port, user, password):
335
 
336
 
337
  # 生成 SSH 密钥对
338
- generate_ssh_key()
339
 
340
- # 复制公钥到远程服务器
341
- copy_public_key_to_remote(frp_url, ssh_port, "root", "qilan")
342
 
343
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
344
 
345
  def requests_retry_session(retries=3, backoff_factor=0.3, status_forcelist=(500, 502, 504), session=None):
346
  """创建一个带重试机制的请求会话"""
@@ -402,11 +417,12 @@ def check_api1():
402
  print("检测到 token")
403
  nn = 0
404
  try:
405
- subprocess.run(f"rsync -avz -e 'ssh -p {ssh_port} -o StrictHostKeyChecking=no' root@{frp_url}:{data_folder}/ {data_folder}/", shell=True, check=True)
 
406
  except subprocess.CalledProcessError as e:
407
  print(f"Rsync 失败,返回码: {e.returncode}")
408
  print(f"Command output: {e.output}")
409
- generate_ssh_key()
410
  # subprocess.run(f"bash /sync.sh -p {ssh_port} -s {frp_url}", shell=True, check=True)
411
  # break # 跳出循环
412
  else:
@@ -587,9 +603,10 @@ def SillyTavern():
587
  # 检查文件是否存在
588
  if not os.path.exists(f'/{huggingface_Data_name}.zip'):
589
  print(f"文件 /{huggingface_Data_name}.zip 不存在,启用实时同步。")
590
- generate_ssh_key()
591
- copy_public_key_to_remote(frp_url, ssh_port, "root", "qilan")
592
- subprocess.run(f"rsync -avz -e 'ssh -p {ssh_port} -o StrictHostKeyChecking=no' root@{frp_url}:{data_folder}/ {data_folder}/", shell=True, check=True)
 
593
  # sys.exit()
594
  else:
595
 
 
25
  [saffg]
26
  type = tcp
27
  local_ip = 127.0.0.1
28
+ local_port = 873
29
  remote_port = 7071
30
  """, '/content/frp/frpc.ini'),
31
 
 
36
 
37
  [safg541211ha]
38
  type=tcp
39
+ local_ip=127.0 .0 .1
40
  local_port=8000
41
  remote_port=7070
42
+ """, '/content/frp/frpc2.ini')
43
+
44
+ # ("""
45
+ # [common]
46
+ # server_addr=47.93.130.208
47
+ # server_port=7000
48
+
49
+ # [sa211lkk1ha]
50
+ # type=tcp
51
+ # local_ip=127.0 .0 .1
52
+ # local_port=8000
53
+ # remote_port=7070
54
+ # """, '/content/frp/frpc3.ini'),
55
+
56
+ # ("""
57
+ # [common]
58
+ # server_addr=175.178.165.186
59
+ # server_port=7000
60
+
61
+ # [safg11ha]
62
+ # type=tcp
63
+ # local_ip=127.0 .0 .1
64
+ # local_port=80000
65
+ # remote port=70700
66
+ # """, '/content/frp/frpc4.ini')
67
  ]
68
  kaggle_metadata = {
69
  "title": "Your Dataset Title",
 
335
 
336
 
337
  # 生成 SSH 密钥对
338
+ # generate_ssh_key()
339
 
340
+ # # 复制公钥到远程服务器
341
+ # copy_public_key_to_remote(frp_url, ssh_port, "root", "qilan")
342
 
343
+ def write_rsyncd_conf(path, port=7071):
344
+ rsyncd_conf_content = f"""
345
+ port = {port}
346
+ [qilan]
347
+ path = {path}
348
+ comment = My rsync module
349
+ read only = no
350
+ list = yes
351
+ """
352
+ with open('/etc/rsyncd.conf', 'w') as f:
353
+ f.write(rsyncd_conf_content.strip())
354
+ print(f"Successfully wrote to /etc/rsyncd.conf for module .")
355
+
356
+ write_rsyncd_conf(data_folder)
357
+ os.system("sudo rsync --daemon")
358
+ os.system("ps aux | grep rsync")
359
 
360
  def requests_retry_session(retries=3, backoff_factor=0.3, status_forcelist=(500, 502, 504), session=None):
361
  """创建一个带重试机制的请求会话"""
 
417
  print("检测到 token")
418
  nn = 0
419
  try:
420
+ subprocess.run(f"rsync -avz --port=7071 ljj@{frp_url}::qilan {data_folder}/", shell=True, check=True)
421
+ # subprocess.run(f"rsync -avz -e 'ssh -p {ssh_port} -o StrictHostKeyChecking=no' root@{frp_url}:{data_folder}/ {data_folder}/", shell=True, check=True)
422
  except subprocess.CalledProcessError as e:
423
  print(f"Rsync 失败,返回码: {e.returncode}")
424
  print(f"Command output: {e.output}")
425
+ # generate_ssh_key()
426
  # subprocess.run(f"bash /sync.sh -p {ssh_port} -s {frp_url}", shell=True, check=True)
427
  # break # 跳出循环
428
  else:
 
603
  # 检查文件是否存在
604
  if not os.path.exists(f'/{huggingface_Data_name}.zip'):
605
  print(f"文件 /{huggingface_Data_name}.zip 不存在,启用实时同步。")
606
+ # generate_ssh_key()
607
+ # copy_public_key_to_remote(frp_url, ssh_port, "root", "qilan")
608
+ # subprocess.run(f"rsync -avz -e 'ssh -p {ssh_port} -o StrictHostKeyChecking=no' root@{frp_url}:{data_folder}/ {data_folder}/", shell=True, check=True)
609
+ subprocess.run(f"rsync -avz --port=7075 ljj@{frp_url}::qilan {data_folder}/", shell=True, check=True)
610
  # sys.exit()
611
  else:
612