Skip to content
  • 版块
  • 最新
  • 标签
  • 热门
  • 用户
  • 群组
皮肤
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • 默认(不使用皮肤)
  • 不使用皮肤
折叠
品牌标识

AIRIOT智慧系统搭建平台经验交流

  1. 主页
  2. 其他功能
  3. 请教下开发python后端服务的一些问题

请教下开发python后端服务的一些问题

已定时 已固定 已锁定 已移动 其他功能
帖子 发布者 浏览
  • 从旧到新
  • 从新到旧
  • 最多赞同
回复
  • 在新帖中回复
登录后回复
此主题已被删除。只有拥有主题管理权限的用户可以查看。
  • J 离线
    J 离线
    Jonathan
    写于 最后由 编辑
    #1

    想基于python-SDK开发一个后端服务,我看了文档对整个流程不是很明白,
    我创建了镜像和app文件,怎样实现服务接口,给前端调用,前端是怎样调用的?

    1 条回复 最后回复
    0
  • 技术支持fx技 离线
    技术支持fx技 离线
    技术支持fx
    写于 最后由 编辑
    #2

    image.png看得是这个文档吗?

    1 条回复 最后回复
    0
  • C 离线
    C 离线
    chenpengchao
    写于 最后由 编辑
    #3

    首先,你要开发一个 http 服务, 把想提供给前端的接口写好。 然后,按照这个文档的说明打包服务(https://docs.airiot.link/development-manual/sdk/develop_service#3-编写-serviceyml 注意: service.yml 文件的内容), 然后把服务部署到平台中, 然后就可以通过平台 /rest/{service.yml文件中的 Path}/接口路径访问到你自己开发的服务了

    J 1 条回复 最后回复
    0
  • J 离线
    J 离线
    Jonathan
    在 中回复了 chenpengchao 最后由 Jonathan 编辑
    #4

    @chenpengchao@Yoki 我的服务本地测试正常,上传到平台后,一直显示重启中是什么原因
    dc81d32e-a21e-409d-b92b-3861d32af102-image.png

    日志报错
    ]OpenBLAS blas_thread_init: pthread_create failed for thread 1 of 16: Operation not permitted
    nOpenBLAS blas_thread_init: ensure that your address space and process count limits are big enough (ulimit -a)
    eOpenBLAS blas_thread_init: or set a smaller OPENBLAS_NUM_THREADS to fit into what you have available
    AOpenBLAS blas_thread_init: RLIMIT_NPROC 40960 current, 40960 max
    ]OpenBLAS blas_thread_init: pthread_create failed for thread 2 of 16: Operation not permitted
    nOpenBLAS blas_thread_init: ensure that your address space and process count limits are big enough (ulimit -a)
    eOpenBLAS blas_thread_init: or set a smaller OPENBLAS_NUM_THREADS to fit into what you have available
    AOpenBLAS blas_thread_init: RLIMIT_NPROC 40960 current, 40960 max
    ]OpenBLAS blas_thread_init: pthread_create failed for thread 3 of 16: Operation not permitted
    nOpenBLAS blas_thread_init: ensure that your address space and process count limits are big enough (ulimit -a)
    eOpenBLAS blas_thread_init: or set a smaller OPENBLAS_NUM_THREADS to fit into what you have available
    AOpenBLAS blas_thread_init: RLIMIT_NPROC 40960 current, 40960 max
    ]OpenBLAS blas_thread_init: pthread_create failed for thread 4 of 16: Operation not permitted
    nOpenBLAS blas_thread_init: ensure that your address space and process count limits are big enough (ulimit -a)
    eOpenBLAS blas_thread_init: or set a smaller OPENBLAS_NUM_THREADS to fit into what you have available
    AOpenBLAS blas_thread_init: RLIMIT_NPROC 40960 current, 40960 max
    ]OpenBLAS blas_thread_init: pthread_create failed for thread 5 of 16: Operation not permitted
    nOpenBLAS blas_thread_init: ensure that your address space and process count limits are big enough (ulimit -a)
    eOpenBLAS blas_thread_init: or set a smaller OPENBLAS_NUM_THREADS to fit into what you have available
    AOpenBLAS blas_thread_init: RLIMIT_NPROC 40960 current, 40960 max
    ]OpenBLAS blas_thread_init: pthread_create failed for thread 6 of 16: Operation not permitted
    nOpenBLAS blas_thread_init: ensure that your address space and process count limits are big enough (ulimit -a)
    eOpenBLAS blas_thread_init: or set a smaller OPENBLAS_NUM_THREADS to fit into what you have available
    AOpenBLAS blas_thread_init: RLIMIT_NPROC 40960 current, 40960 max
    ]OpenBLAS blas_thread_init: pthread_create failed for thread 7 of 16: Operation not permitted
    nOpenBLAS blas_thread_init: ensure that your address space and process count limits are big enough (ulimit -a)
    eOpenBLAS blas_thread_init: or set a smaller OPENBLAS_NUM_THREADS to fit into what you have available
    AOpenBLAS blas_thread_init: RLIMIT_NPROC 40960 current, 40960 max
    ]OpenBLAS blas_thread_init: pthread_create failed for thread 8 of 16: Operation not permitted
    nOpenBLAS blas_thread_init: ensure that your address space and process count limits are big enough (ulimit -a)
    eOpenBLAS blas_thread_init: or set a smaller OPENBLAS_NUM_THREADS to fit into what you have available
    AOpenBLAS blas_thread_init: RLIMIT_NPROC 40960 current, 40960 max
    ]OpenBLAS blas_thread_init: pthread_create failed for thread 9 of 16: Operation not permitted
    nOpenBLAS blas_thread_init: ensure that your address space and process count limits are big enough (ulimit -a)
    eOpenBLAS blas_thread_init: or set a smaller OPENBLAS_NUM_THREADS to fit into what you have available
    AOpenBLAS blas_thread_init: RLIMIT_NPROC 40960 current, 40960 max
    ^OpenBLAS blas_thread_init: pthread_create failed for thread 10 of 16: Operation not permitted
    nOpenBLAS blas_thread_init: ensure that your address space and process count limits are big enough (ulimit -a)
    eOpenBLAS blas_thread_init: or set a smaller OPENBLAS_NUM_THREADS to fit into what you have available
    AOpenBLAS blas_thread_init: RLIMIT_NPROC 40960 current, 40960 max
    ^OpenBLAS blas_thread_init: pthread_create failed for thread 11 of 16: Operation not permitted
    nOpenBLAS blas_thread_init: ensure that your address space and process count limits are big enough (ulimit -a)
    eOpenBLAS blas_thread_init: or set a smaller OPENBLAS_NUM_THREADS to fit into what you have available
    AOpenBLAS blas_thread_init: RLIMIT_NPROC 40960 current, 40960 max
    ^OpenBLAS blas_thread_init: pthread_create failed for thread 12 of 16: Operation not permitted
    nOpenBLAS blas_thread_init: ensure that your address space and process count limits are big enough (ulimit -a)
    eOpenBLAS blas_thread_init: or set a smaller OPENBLAS_NUM_THREADS to fit into what you have available
    AOpenBLAS blas_thread_init: RLIMIT_NPROC 40960 current, 40960 max
    ^OpenBLAS blas_thread_init: pthread_create failed for thread 13 of 16: Operation not permitted
    nOpenBLAS blas_thread_init: ensure that your address space and process count limits are big enough (ulimit -a)
    eOpenBLAS blas_thread_init: or set a smaller OPENBLAS_NUM_THREADS to fit into what you have available
    AOpenBLAS blas_thread_init: RLIMIT_NPROC 40960 current, 40960 max
    ^OpenBLAS blas_thread_init: pthread_create failed for thread 14 of 16: Operation not permitted
    nOpenBLAS blas_thread_init: ensure that your address space and process count limits are big enough (ulimit -a)
    eOpenBLAS blas_thread_init: or set a smaller OPENBLAS_NUM_THREADS to fit into what you have available
    AOpenBLAS blas_thread_init: RLIMIT_NPROC 40960 current, 40960 max
    ^OpenBLAS blas_thread_init: pthread_create failed for thread 15 of 16: Operation not permitted
    nOpenBLAS blas_thread_init: ensure that your address space and process count limits are big enough (ulimit -a)
    eOpenBLAS blas_thread_init: or set a smaller OPENBLAS_NUM_THREADS to fit into what you have available
    AOpenBLAS blas_thread_init: RLIMIT_NPROC 40960 current, 40960 max
    #Traceback (most recent call last):
    * File "/app/app.py", line 2, in <module>
    1 from data_analysis import DATimingDataClient
    4 File "/app/data_analysis.py", line 8, in <module>
     import pandas as pd
    Z File "/usr/local/lib/python3.10/site-packages/pandas/init.py", line 14, in <module>
     import(_dependency)
    Z File "/usr/local/lib/python3.10/site-packages/numpy/init.py", line 114, in <module>
    - from numpy.config import show_config
    Z File "/usr/local/lib/python3.10/site-packages/numpy/config.py", line 4, in <module>
    0 from numpy._core.multiarray_umath import (
    
    File "/usr/local/lib/python3.10/site-packages/numpy/_core/init.py", line 23, in <module>
     from . import multiarray
    a File "/usr/local/lib/python3.10/site-packages/numpy/core/multiarray.py", line 10, in <module>
     from . import overrides
    
    File "/usr/local/lib/python3.10/site-packages/numpy/_core/overrides.py", line 7, in <module>
    0 from numpy._core._multiarray_umath import (
    E File "<frozen importlib._bootstrap>", line 1022, in _find_and_load
    KeyboardInterrupt
    怎么解决

    1 条回复 最后回复
    0
  • C 离线
    C 离线
    chenpengchao
    写于 最后由 chenpengchao 编辑
    #5
    1. 检查一下服务器上 ulimit 设置
    2. 检查 docker-compose.yml 你自己写的这个服务的 ulimits 设置
    J 1 条回复 最后回复
    0
  • J 离线
    J 离线
    Jonathan
    在 中回复了 chenpengchao 最后由 Jonathan 编辑
    #6

    @chenpengchao 在 请教下开发python后端服务的一些问题 中说:

    docker-compose.yml

    现在服务运行起来了,怎样访问
     * Serving Flask app 'app'
     * Debug mode: on
    �WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
    & * Running on all addresses (0.0.0.0)
    $ * Running on http://127.0.0.1:5000
    & * Running on http://172.19.0.61:5000
    Press CTRL+C to quit
     * Restarting with stat
     * Debugger is active!
     * Debugger PIN: 131-320-878

    我按文档访问这个我的服务接口http://ip:31000/da/api/data没有返回

    服务日志里显示收到了访问请求
    R172.19.0.18 - - [19/Dec/2024 16:14:18] "GET /da/api/data HTTP/1.1" 404 -
    R172.19.0.18 - - [19/Dec/2024 16:14:21] "GET /da/api/data HTTP/1.1" 404 -
    R172.19.0.18 - - [19/Dec/2024 16:14:41] "GET /da/api/data HTTP/1.1" 404 -
    R172.19.0.18 - - [19/Dec/2024 16:15:15] "GET /da/api/data HTTP/1.1" 404 -
    R172.19.0.18 - - [19/Dec/2024 16:18:22] "GET /da/api/data HTTP/1.1" 404 -
    J172.19.0.18 - - [19/Dec/2024 16:18:56] "GET /da/ HTTP/1.1" 404 -
    I172.19.0.18 - - [19/Dec/2024 16:19:12] "GET /da HTTP/1.1" 404 -
    R172.19.0.18 - - [19/Dec/2024 16:19:56] "GET /da/api/data HTTP/1.1" 404 -

    出现了404错误,服务本地测试是可以的

    1 条回复 最后回复
    0
  • C 离线
    C 离线
    chenpengchao
    写于 最后由 编辑
    #7

    发一下 docker-compose.yml 和你自己开发服务的 service.yml 文件的内容

    J 1 条回复 最后回复
    0
  • J 离线
    J 离线
    Jonathan
    在 中回复了 chenpengchao 最后由 Jonathan 编辑
    #8

    @chenpengchao
    da:
    container_name: da
    image: 'da:latest'
    labels:
    - traefik.enable=true
    - traefik.http.routers.da.entrypoints=web
    - traefik.http.services.da.loadbalancer.server.port=31000
    - traefik.http.routers.da.rule=PathPrefix(/da)
    - service.repo=da
    - security-opt seccomp=unconfned
    logging:
    driver: json-file
    options:
    max-size: 100m
    max-file: '1'
    networks:
    - backend
    privileged: true
    restart: always
    ulimits:
    nproc: 40960
    nofile:
    soft: 10240
    hard: 30720
    volumes:
    - '/etc/localtime:/etc/localtime:ro'

    service.yml 文件的内容:

    Name: da

    Path: /da

    Version: 1.0.0

    Description: data_ana

    GroupName: server

    Service: Internal

    Ports:

    • Host: "31000" # 映射到宿主机的端口号, 如果不填写, 则会随机分配一个端口号
      Container: "31000" # 服务监听的端口号, 即配置文件中 server.port 的值
      Protocol: "" # 协议类型, 可选项有 TCP UDP, 如果不填写, 则默认为 TCP
    1 条回复 最后回复
    0
  • C 离线
    C 离线
    chenpengchao
    写于 最后由 编辑
    #9
    1. 你服务日志里监听的是 5000 端口,但是你 service.yml 中写的是 31000, 对不上
    2. 你的服务需要有一个统一的请求前缀 /da
    3. 不要用 31000 端口,这个是平台网关的端
    4. 如果你不通过平台网关访问服务的话,把 service.yml 中的 Service: Internal 改成 Service: External,而且 Container 填写的端口要和你实际监听的端口一致,但是实际访问端口要用 Host 的端口,或者平台随机生成的那个端口
    J 2 条回复 最后回复
    0
  • J 离线
    J 离线
    Jonathan
    在 中回复了 chenpengchao 最后由 Jonathan 编辑
    #10
    此回复已被删除!
    1 条回复 最后回复
    0
  • J 离线
    J 离线
    Jonathan
    在 中回复了 chenpengchao 最后由 编辑
    #11

    @chenpengchao 通过平台网关访问服务是什么意思
    我的服务/api/data接口没加/da前缀,访问ip:5000/api/data可以成功,访问ip:5000/da/api/data失败,感觉/da可要可不要,service.yml里的定义没起到作用

    1 条回复 最后回复
    0

  • 登录

  • 没有帐号? 注册

  • 登录或注册以进行搜索。
  • 第一个帖子
    最后一个帖子
0
  • 版块
  • 最新
  • 标签
  • 热门
  • 用户
  • 群组