seatools-starter-server-uvicorn


Nameseatools-starter-server-uvicorn JSON
Version 1.0.3 PyPI version JSON
download
home_pageNone
SummarySeatools Starter Server Uvicorn
upload_time2024-12-19 03:41:35
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseNone
keywords seatools server uvicorn
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # seatools uvicorn 服务器启动器

该框架在`uvicorn`层完成`seatools.ioc`的加载, 使用该项目后无需在每个进程额外执行`seatools.ioc.run`函数, 仅在启动时传递一个`ioc`启动的函数即可

## 使用指南
1. 安装, `poetry add seatools-starter-server-uvicorn`
2. 这里以`fastapi`为例, 假设`xxx.boot`模块存在`start`的自定义启动`ioc`函数

```python
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. 程序直接调用

```python
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()

```
4. 支持配置`config/application.yml`
```yaml
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
      # ...
    
```
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "seatools-starter-server-uvicorn",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "seatools, server, uvicorn",
    "author": null,
    "author_email": "seatools-py <521274311@qq.com>",
    "download_url": "https://files.pythonhosted.org/packages/54/a4/ca4cb3b77b127fb822070c05e6612e9d9750104170cffc628fcd8f3ba700/seatools_starter_server_uvicorn-1.0.3.tar.gz",
    "platform": null,
    "description": "# seatools uvicorn \u670d\u52a1\u5668\u542f\u52a8\u5668\n\n\u8be5\u6846\u67b6\u5728`uvicorn`\u5c42\u5b8c\u6210`seatools.ioc`\u7684\u52a0\u8f7d, \u4f7f\u7528\u8be5\u9879\u76ee\u540e\u65e0\u9700\u5728\u6bcf\u4e2a\u8fdb\u7a0b\u989d\u5916\u6267\u884c`seatools.ioc.run`\u51fd\u6570, \u4ec5\u5728\u542f\u52a8\u65f6\u4f20\u9012\u4e00\u4e2a`ioc`\u542f\u52a8\u7684\u51fd\u6570\u5373\u53ef\n\n## \u4f7f\u7528\u6307\u5357\n1. \u5b89\u88c5, `poetry add seatools-starter-server-uvicorn`\n2. \u8fd9\u91cc\u4ee5`fastapi`\u4e3a\u4f8b, \u5047\u8bbe`xxx.boot`\u6a21\u5757\u5b58\u5728`start`\u7684\u81ea\u5b9a\u4e49\u542f\u52a8`ioc`\u51fd\u6570\n\n```python\nfrom seatools.ioc import run\n\n\ndef start():\n    run(scan_package_names='xxx', config_dir='./config')\n\n```\n\u547d\u4ee4\u884c\u542f\u52a8`uvicorn xxx.boot:start xxx.fastapi.app:app`, \u5176\u4ed6\u53c2\u6570\u4e0e\u5b98\u65b9`uvicorn`\u4e00\u81f4, \u5728`uvicorn`\u57fa\u7840\u4e0a\u589e\u52a0\u4e86\u4e00\u4e2a`ioc_app`\u7684\u53c2\u6570, \u9700\u8981\u6307\u660e`ioc`\u5e94\u7528\u542f\u52a8\u7684\u51fd\u6570\n\u82e5\u914d\u7f6e`application.yml`\u6216`application-[*].yml`\u4e2d\u5b58\u5728`seatools.server.uvicorn.app`\u914d\u7f6e, \u5219\u53ef\u4e0d\u4f20\u9012`uvicorn`\u7684`app`\u4ec5\u4f20\u9012`ioc_app`\u5373\u53ef, \u793a\u4f8b`uvicorn xxx.boot:start`\n\u82e5\u540c\u65f6\u4f7f\u7528\u4e86`seatools-starter-web-*`\u7684`web`\u542f\u52a8\u5305, \u5219`uvicorn`\u7684`app`\u76f4\u63a5\u53ef\u7701\u7565\n3. \u7a0b\u5e8f\u76f4\u63a5\u8c03\u7528\n\n```python\nfrom xxx.boot import start\nfrom seatools.ioc.server import uvicorn\n\n\ndef main():\n    uvicorn.run(\n        start,\n        'xxx.fastapi.app:app' # \u914d\u7f6e\u4e2dseatools.server.uvicorn.app\u5b58\u5728 \u6216 \u5b89\u88c5\u4e86seatools-starter-web-fastapi \u6b64\u5904\u53ef\u4e0d\u586b\n    )\n\n\nif __name__ == '__main__':\n    main()\n\n```\n4. \u652f\u6301\u914d\u7f6e`config/application.yml`\n```yaml\nseatools:\n  server:\n    uvicorn:\n      # \u914d\u7f6e\u8be5\u53c2\u6570\u540e\u542f\u52a8\u53c2\u6570\u53ef\u5ffd\u7565app\u53c2\u6570, \u914d\u7f6e\u4e0e\u5b98\u65b9uvicorn.run\u4e00\u81f4, \u82e5\u5b89\u88c5 seatools-starter-web-fastapi\u53ef\u7701\u7565app\u914d\u7f6e \n      app: xxx.fastapi.app:app\n      host: 127.0.0.1\n      port: 8000\n      workers: 1\n      # ...\n    \n```",
    "bugtrack_url": null,
    "license": null,
    "summary": "Seatools Starter Server Uvicorn",
    "version": "1.0.3",
    "project_urls": {
        "Homepage": "https://github.com/seatools-py/seatools-starter-server-uvicorn",
        "Issues": "https://github.com/seatools-py/seatools-starter-server-uvicorn/issues"
    },
    "split_keywords": [
        "seatools",
        " server",
        " uvicorn"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3d093c62470e7701c1be55612e57c360f7783dbbcc28f4a3c7fa6736efe620e1",
                "md5": "7da4d6ae59022f65703c6c747fd1f8eb",
                "sha256": "391c97533c57eeccf2b8198a0ad2f8087c923de6cf07491a70385079a5f58b74"
            },
            "downloads": -1,
            "filename": "seatools_starter_server_uvicorn-1.0.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7da4d6ae59022f65703c6c747fd1f8eb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 9474,
            "upload_time": "2024-12-19T03:41:32",
            "upload_time_iso_8601": "2024-12-19T03:41:32.798507Z",
            "url": "https://files.pythonhosted.org/packages/3d/09/3c62470e7701c1be55612e57c360f7783dbbcc28f4a3c7fa6736efe620e1/seatools_starter_server_uvicorn-1.0.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "54a4ca4cb3b77b127fb822070c05e6612e9d9750104170cffc628fcd8f3ba700",
                "md5": "5b654e5a1516e89ef1cce87203632262",
                "sha256": "ae4072dcdb37b5478dc1699f7dd7ae1f87dc75debc177457730c60227fa139cd"
            },
            "downloads": -1,
            "filename": "seatools_starter_server_uvicorn-1.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "5b654e5a1516e89ef1cce87203632262",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 8255,
            "upload_time": "2024-12-19T03:41:35",
            "upload_time_iso_8601": "2024-12-19T03:41:35.140050Z",
            "url": "https://files.pythonhosted.org/packages/54/a4/ca4cb3b77b127fb822070c05e6612e9d9750104170cffc628fcd8f3ba700/seatools_starter_server_uvicorn-1.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-19 03:41:35",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "seatools-py",
    "github_project": "seatools-starter-server-uvicorn",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "seatools-starter-server-uvicorn"
}
        
Elapsed time: 0.42091s