seatools uvicorn 服务器启动器
该框架在uvicorn层完成seatools.ioc的加载, 使用该项目后无需在每个进程额外执行seatools.ioc.run函数, 仅在启动时传递一个ioc启动的函数即可
版本说明
- 1.0.4 版本支持 uvicorn>=0.36 版本
- 1.0.3 版本支持 uvicorn<=0.35 版本
使用指南
- 安装,
poetry add seatools-starter-server-uvicorn - 这里以
fastapi为例, 假设xxx.boot模块存在start的自定义启动ioc函数
from seatools.ioc import run
def start():
run(scan_package_names='xxx', config_dir='./config')
命令行启动uvicorn xxx.boot:start xxx.fastapi.app:app, 其他参数与官方uvicorn一致, 在uvicorn基础上增加了一个ioc_app的参数, 需要指明ioc应用启动的函数
若配置application.yml或application-[*].yml中存在seatools.server.uvicorn.app配置, 则可不传递uvicorn的app仅传递ioc_app即可, 示例uvicorn xxx.boot:start
若同时使用了seatools-starter-web-*的web启动包, 则uvicorn的app直接可省略
3. 程序直接调用
from xxx.boot import start
from seatools.ioc.server import uvicorn
def main():
uvicorn.run(
start,
'xxx.fastapi.app:app' # 配置中seatools.server.uvicorn.app存在 或 安装了seatools-starter-web-fastapi 此处可不填
)
if __name__ == '__main__':
main()
- 支持配置
config/application.yml
seatools:
server:
uvicorn:
# 配置该参数后启动参数可忽略app参数, 配置与官方uvicorn.run一致, 若安装 seatools-starter-web-fastapi可省略app配置
app: xxx.fastapi.app:app
host: 127.0.0.1
port: 8000
workers: 1
# ...
Metadata
Release files for seatools-starter-server-uvicorn 1.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| seatools_starter_server_uvicorn-1.0.4.tar.gz | 8.6 kB | Without provenance | Details for seatools_starter_server_uvicorn-1.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| seatools_starter_server_uvicorn-1.0.4-py3-none-any.whl | Python 3 | none | any | Details for seatools_starter_server_uvicorn-1.0.4-py3-none-any.whl |
Total release size: 11.9 kB
Release files / seatools_starter_server_uvicorn-1.0.4.tar.gz
| Download URL | seatools_starter_server_uvicorn-1.0.4.tar.gz |
|---|---|
| Size | 8.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
243591429e0b410443b897b075e3e8a73e9e5c2b3841096d2315336a99f6b3dc
|
|
BLAKE2b-256 checksum How to use checksums |
78fb5ad31891609d80b24b106d1803357db5c28c39693327296fbd7af977d349
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.11
|
Release files / seatools_starter_server_uvicorn-1.0.4-py3-none-any.whl
| Download URL | seatools_starter_server_uvicorn-1.0.4-py3-none-any.whl |
|---|---|
| Size | 3.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7137de5deaa9742c3b88d75ce1fe843f58ab4fb0d456f8793b1909af66c5eb10
|
|
BLAKE2b-256 checksum How to use checksums |
cab6e555b620f5493b56b10047189c71bf8aaef2e34b455094ac7fd315d98bcd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.11
|
Security for seatools-starter-server-uvicorn 1.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.