# antcook **Repository Path**: techbrew/antcook ## Basic Information - **Project Name**: antcook - **Description**: No description available - **Primary Language**: Python - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-03-31 - **Last Updated**: 2022-03-16 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## 1. 运行环境 Python3.8 ### 1.1. 安装系统依赖 ```shell script sudo apt-get update sudo apt-get install -y git nano nginx supervisor sudo apt-get install -y build-essential python3-venv python3-dev python3-pip python3-setuptools python3-wheel python3-cffi libcairo2 libpango-1.0-0 libpangocairo-1.0-0 libgdk-pixbuf2.0-0 libffi-dev shared-mime-info ``` ### 1.2. 安装 PostgreSQL 数据库 ```shell script # 添加 key sudo apt-get install curl ca-certificates gnupg curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - # 添加源 sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' # 安装数据库 sudo apt-get update sudo apt-get install postgresql ``` ### 1.3. 更新 pip 及安装 uwsgi ```shell script pip3 install --upgrade setuptools pip pip install uwsgi ``` ### 1.4. 安装 redis ```shell script sudo apt update sudo apt install redis-server nano /etc/redis/redis.conf sudo service redis restart ``` ## 2. 服务安装 ### 2.1. 进入目录,拉取代码 ```sh cd /opt git clone https://gitee.com/techbrew/antcook.git ``` ### 2.2. 进入项目路径 ```sh cd /opt/antcook ``` ### 2.3. 创建虚拟环境并启动虚拟环境 ```sh python3 -m venv venv source venv/bin/activate ``` ### 2.4. 安装依赖 ```sh pip install --upgrade setuptools pip pip install -r requirements.txt ``` ### 2.5. 启动 uwsgi ```shell script cd /opt/antcook && source venv/bin/activate uwsgi --ini /opt/antcook/antcook_uwsgi.ini ``` ### 2.6. 更新服务 ```shell script cd /opt/antcook && source venv/bin/activate git pull python3 manage.py migrate ps auxw | grep antcook_uwsgi uwsgi --reload /opt/antcook/uwsgi/uwsgi.pid ps auxw | grep antcook_uwsgi ``` ### 2.7. Supervisor 服务配置 输入以下命令可得到配置文件: ```sh echo_supervisord_conf ``` 或者: ```shell cat /etc/supervisor/supervisord.conf ``` 在目录/etc/supervisor/conf.d/下创建 antcook_supervisord.conf ```sh cd /etc/supervisor/conf.d/ ``` 配置文件 ```sh nano /etc/supervisor/conf.d/antcook_supervisord.conf ``` supervisor基本命令(后四个命令可以省略“-c supervisor.conf”): ```shell supervisord -c /etc/supervisor/supervisord.conf 通过配置文件启动supervisor ``` ```shell supervisorctl update 更新新的配置到supervisord supervisorctl status 查看状态 supervisorctl reload 重新载入配置文件 supervisorctl start [all]|[x] 启动所有/指定的程序进程 supervisorctl stop [all]|[x] 关闭所有/指定的程序进程 supervisorctl restart uwsgi.product 重新载入配置文件 supervisorctl -c /etc/supervisor/supervisor.conf status 查看状态 supervisorctl -c /etc/supervisor/supervisor.conf reload 重新载入配置文件 supervisorctl -c /etc/supervisor/supervisor.conf start [all]|[x] 启动所有/指定的程序进程 supervisorctl -c /etc/supervisor/supervisor.conf stop [all]|[x] 关闭所有/指定的程序进程 ``` 查看运行状态 ```sh supervisorctl status ``` ### 安装 docker compose https://docs.docker.com/compose/cli-command/#install-on-linux ```shell DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker} mkdir -p $DOCKER_CONFIG/cli-plugins curl -SL https://get.daocloud.io/docker/compose/releases/download/v2.3.3/docker-compose-linux-x86_64 -o $DOCKER_CONFIG/cli-plugins/docker-compose chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose ```