fastapi + uvicorn + gunicorn部署时run命令(20210308在用)

fastapi + uvicorn + gunicorn部署时run命令(20210308在用)

run docker

docker run -d \
--name mqsub \
--restart=always \
--network php-net \
-p 8000:80 \
-v /root/mqsub:/app \
-e KEEP_ALIVE="20" \
-e GRACEFUL_TIMEOUT="20" \
-e TIMEOUT="20" \
mqsub /start-reload.sh

fastapi uvicorn 部署Dockerfile(20210308在用)

#FROM centos/python-36-centos7
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.7
MAINTAINER sam
USER root

WORKDIR /app

# 下载pip包
RUN python -m pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple

RUN pip install requests -i https://pypi.tuna.tsinghua.edu.cn/simple

RUN pip install wheel -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install pycrypto -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install mq_http_sdk  -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install aliyunsdkcore -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple aliyun-python-sdk-iot

RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple fastapi
RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pydantic
RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple uvicorn

#COPY requirements.txt /home/requirements.txt

# 使用淘宝的npm镜像
#RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn
#RUN pip install -r requirements.txt

#ENTRYPOINT [ "/bin/bash", "/home/entry-point.sh"]
#ENTRYPOINT  uwsgi --ini /home/hello.ini
#CMD ["uwsgi","--ini", "/home/hello.ini"] #启动uwsgi

nodejs的docker运行命令

docker run -d \
    --restart=always \
    -v /root/xy.api:/app \
    --network php-net \
    -p 3000:3000 \
    --name xyys.nodejs \   #镜像名
    xyys.nodejs \          #容器名
    node /app/app.js    #运行命令

php的docker运行命令

docker run -d \
--restart=always \
--name php-web \
--network php-net \
-p 9001:9000 \
-v /www/nginx/apps:/usr/share/nginx/html \
php:5.6-fpm

建立镜像命令

sudo docker build -t mqsub .

查看docker ip地址

#查看IP;
[root@localhost ~]# docker inspect myphp-fpm | grep "IPAddress"
 "SecondaryIPAddresses": null,
 "IPAddress": "172.17.0.3",
 "IPAddress": "172.17.0.3",
#创建一个docker网络,使用docker来连接多个容器
[root@localhost ~]# docker network create -d bridge php-net
#加入docker网络的容器执行 docker run 命令时要加参数:--network
--network php-net \

docker镜像image拉取速度过慢 - 仓库源:中科大速度最快(docker pull)

#创建、修改配置文件: /etc/docker/daemon.json 
vim /etc/docker/daemon.json          # 编辑daemon.json 
{
    "registry-mirrors": ["http://docker.mirrors.ustc.edu.cn"] 
} 
systemctl restart docker                  # 重启docker服务

如何改变

*强调

适合你的列表

  • 项目
    • 项目
      • 项目
  1. 项目1
  2. 项目2
  3. 项目3
  • 计划任务
  • 完成任务

一个表格

一个简单的表格是这么创建的:

项目Value
电脑$1600
手机$12
导管$1
FastAPI是一个现代、快速(高性能)的Web框架,它使用最新的ASGI标准。Gunicorn是一个使用WSGI标准的应用服务器,它可以直接运行Flask和Django,但不能直接运行FastAPI。为了在部署FastAPI使用Gunicorn,可以借助uvicorn工作器。可以使用以下命令来启动FastAPI应用程序: ``` gunicorn main:app --workers 2 --worker-class uvicorn.workers.UvicornWorker --bind 0.0.0.0:8000 ``` 这个命令中,`main`是你的应用程序的入口文件名,`app`是FastAPI应用程序的实例名。`--workers 2`表示使用2个工作进程,`--worker-class uvicorn.workers.UvicornWorker`表示使用uvicorn工作器,`--bind 0.0.0.0:8000`表示绑定到0.0.0.0的8000端口。这样就可以使用Gunicornuvicorn工作器来部署FastAPI应用程序了。123 #### 引用[.reference_title] - *1* *2* [ubuntu+nginx+gunicorn+uvicorn+fastapi](https://blog.csdn.net/qq_41960127/article/details/128832617)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}} ] [.reference_item] - *3* [Docker生产环境部署FastAPI+supervisor+gunicorn+nginx](https://blog.csdn.net/weixin_45457042/article/details/129213133)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值