- 优化Windows打包

This commit is contained in:
jxxghp 2023-10-10 09:50:37 +08:00
parent 65b5219e45
commit 60140fd2e6
6 changed files with 58 additions and 10 deletions

View File

@ -77,6 +77,22 @@ jobs:
pip install -r requirements.txt pip install -r requirements.txt
shell: pwsh shell: pwsh
- name: Prepare Frontend
run: |
Invoke-WebRequest -Uri "http://nginx.org/download/nginx-1.25.2.zip" -OutFile "nginx.zip"
Expand-Archive -Path "nginx.zip" -DestinationPath "nginx-1.25.2"
Move-Item -Path "nginx-1.25.2/nginx-1.25.2" -Destination "nginx"
Remove-Item -Path "nginx.zip"
Remove-Item -Path "nginx-1.25.2" -Recurse -Force
$FRONTEND_VERSION = (Invoke-WebRequest -Uri "https://api.github.com/repos/jxxghp/MoviePilot-Frontend/releases/latest" | ConvertFrom-Json).tag_name
Invoke-WebRequest -Uri "https://github.com/jxxghp/MoviePilot-Frontend/releases/download/$FRONTEND_VERSION/dist.zip" -OutFile "dist.zip"
Expand-Archive -Path "dist.zip" -DestinationPath "dist"
Move-Item -Path "dist/dist/*" -Destination "nginx/html" -Force
Remove-Item -Path "dist.zip"
Remove-Item -Path "dist" -Recurse -Force
Move-Item -Path "nginx/html/nginx.conf" -Destination "nginx/conf/nginx.conf" -Force
shell: pwsh
- name: Pyinstaller - name: Pyinstaller
run: | run: |
pyinstaller windows.spec pyinstaller windows.spec

View File

@ -39,19 +39,17 @@ MoviePilot需要配套下载器和媒体服务器配合使用。
docker pull jxxghp/moviepilot:latest docker pull jxxghp/moviepilot:latest
``` ```
- Window - Windows
后端https://github.com/jxxghp/MoviePilot/releases 下载 [MoviePilot.exe](https://github.com/jxxghp/MoviePilot/releases),双击运行后自动生成配置文件目录。
前端https://github.com/jxxghp/MoviePilot-Frontend/releases
## 配置 ## 配置
项目的所有配置均通过环境变量进行设置,支持两种配置方式: 项目的所有配置均通过环境变量进行设置,支持两种配置方式:
- 在docker环境变量部分进行参数配置部分环境建立容器后会自动显示待配置项,如未自动显示配置项则需要手动增加对应环境变量。 - 在Docker环境变量部分或Wdinows系统环境变量中进行参数配置,如未自动显示配置项则需要手动增加对应环境变量。
- 下载 [app.env](https://github.com/jxxghp/MoviePilot/raw/main/config/app.env) 文件,修改好配置后放置到配置文件映射路径根目录,配置项可根据说明自主增减。 - 下载 [app.env](https://github.com/jxxghp/MoviePilot/raw/main/config/app.env) 配置文件,修改好配置后放置到配置文件映射路径根目录,配置项可根据说明自主增减。
配置文件映射路径:`/config`,配置项生效优先级:环境变量 > env文件 > 默认值,部分参数如路径映射、站点认证、权限端口等必须通过环境变量进行配置。 配置文件映射路径:`/config`,配置项生效优先级:环境变量 > env文件 > 默认值,**部分参数如路径映射、站点认证、权限端口、时区等必须通过环境变量进行配置**
> $\color{red}{*}$ 号标识的为必填项,其它为可选项,可选项可删除配置变量从而使用默认值。 > $\color{red}{*}$ 号标识的为必填项,其它为可选项,可选项可删除配置变量从而使用默认值。

View File

@ -1,4 +1,3 @@
import os
import secrets import secrets
import sys import sys
from pathlib import Path from pathlib import Path

View File

@ -1,4 +1,5 @@
import multiprocessing import multiprocessing
from pathlib import Path
import uvicorn as uvicorn import uvicorn as uvicorn
from fastapi import FastAPI from fastapi import FastAPI
@ -13,6 +14,7 @@ from app.db.init import init_db, update_db
from app.helper.display import DisplayHelper from app.helper.display import DisplayHelper
from app.helper.sites import SitesHelper from app.helper.sites import SitesHelper
from app.scheduler import Scheduler from app.scheduler import Scheduler
from app.utils.system import SystemUtils
# App # App
App = FastAPI(title=settings.PROJECT_NAME, App = FastAPI(title=settings.PROJECT_NAME,
@ -44,6 +46,34 @@ def init_routers():
App.include_router(arr_router, prefix="/api/v3") App.include_router(arr_router, prefix="/api/v3")
def start_frontend():
"""
启动前端服务
"""
if not SystemUtils.is_frozen():
return
if SystemUtils.is_windows():
nginx_path = settings.ROOT_PATH / 'nginx' / 'nginx.exe'
else:
nginx_path = settings.ROOT_PATH / 'nginx' / 'nginx'
if Path(nginx_path).exists():
import subprocess
subprocess.Popen(f"start {nginx_path}", shell=True)
def stop_frontend():
"""
停止前端服务
"""
if not SystemUtils.is_frozen():
return
import subprocess
if SystemUtils.is_windows():
subprocess.Popen(f"taskkill /f /im nginx.exe", shell=True)
else:
subprocess.Popen(f"killall nginx", shell=True)
@App.on_event("shutdown") @App.on_event("shutdown")
def shutdown_server(): def shutdown_server():
""" """
@ -59,6 +89,8 @@ def shutdown_server():
DisplayHelper().stop() DisplayHelper().stop()
# 停止定时服务 # 停止定时服务
Scheduler().stop() Scheduler().stop()
# 停止前端服务
stop_frontend()
@App.on_event("startup") @App.on_event("startup")
@ -66,7 +98,7 @@ def start_module():
""" """
启动模块 启动模块
""" """
# 虚显示 # 虚显示
DisplayHelper() DisplayHelper()
# 站点管理 # 站点管理
SitesHelper() SitesHelper()
@ -80,6 +112,8 @@ def start_module():
Command() Command()
# 初始化路由 # 初始化路由
init_routers() init_routers()
# 启动前端服务
start_frontend()
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -1 +1 @@
APP_VERSION = 'v1.3.0' APP_VERSION = 'v1.3.0-1'

View File

@ -77,6 +77,7 @@ exe = EXE(
a.zipfiles, a.zipfiles,
a.datas, a.datas,
collect_pkg_data('config'), collect_pkg_data('config'),
collect_pkg_data('nginx'),
collect_pkg_data('cf_clearance'), collect_pkg_data('cf_clearance'),
collect_pkg_data('database', include_py_files=True), collect_pkg_data('database', include_py_files=True),
[], [],