File size: 1,837 Bytes
a7a7051
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### 启动voltaml (有输出日志..)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import multiprocessing\n",
    "import time\n",
    "import subprocess\n",
    "\n",
    "use_ngrok = True\n",
    "use_cloudflare = True\n",
    "\n",
    "def start_tunnel():\n",
    "    if use_ngrok:\n",
    "        from pyngrok import ngrok\n",
    "        ngrok_tunnel = ngrok.connect(5003, \"http\")\n",
    "        print(\"ngrok_tunnel:\", ngrok_tunnel)\n",
    "    if use_cloudflare:\n",
    "        from pycloudflared import try_cloudflare\n",
    "        cloudflare_url = try_cloudflare(5003, verbose=False)\n",
    "        print(\"cloudflare_tunnel:\", cloudflare_url)\n",
    "\n",
    "def voltaML_start():\n",
    "    print(\"启动alist...\")\n",
    "    process = subprocess.Popen([\"python\", \"main.py\"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n",
    "    for line in process.stdout:\n",
    "        output = line.decode().strip()\n",
    "        if output:\n",
    "            print(output)\n",
    "\n",
    "voltaML_process = multiprocessing.Process(target=voltaML_start)\n",
    "voltaML_process.start()\n",
    "time.sleep(3)\n",
    "\n",
    "start_tunnel()\n",
    "\n",
    "# 提示用户如何暂停代码的执行\n",
    "print(\"代码正在运行中。要手动暂停代码的执行,请点击左侧的暂停按钮。\")\n",
    "\n",
    "# 检查voltaML_process进程是否仍在运行\n",
    "while voltaML_process.is_alive():\n",
    "    time.sleep(1)\n",
    "\n",
    "print(\"主程序继续执行...\")"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}