# analyze_api **Repository Path**: luo-wenjie12/analyze_api ## Basic Information - **Project Name**: analyze_api - **Description**: 数据分析 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-04-16 - **Last Updated**: 2024-04-16 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## 项目简介 主动服务数据分析接口服务 - python3.8.8 - flask1.1.2 ## 项目环境 | profile环境 | 说明 | | -------------------- | -------------------------- | | localhost | 本地测试环境 | | beta | beta测试环境 | | pro | 正式环境 | ## 项目结构 | 包 | 说明 | | -------------------- | -------------------------- | | base | 基础包 | | common | 公共包,启动参数设置,日志 ,全局变量设置 | | v1 | 业务包 | ## 常用命令 | 命令 | 说明 | | -------------------- | -------------------------- | | pip freeze >requirements.txt | 输出依赖包到文件 | | pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple | | | python app.py --profile=localhost | 运行程序,如果使用pycharm,对app.py右键run/debug进行运行 | ## 创建虚拟环境 https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/ 以https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-5.3.1-Linux-x86.sh为例 | 步骤 | 说明 | | -------------------- | -------------------------- | | wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-5.3.1-Linux-x86.sh | 下载Anaconda3-5.3.1-Linux-x86.sh | | ./Anaconda3-5.3.1-Linux-x86.sh | 安装Anaconda3-5.3.1-Linux-x86.sh | | pip install -r requirements.txt | 安装依赖包,requirements.txt对应项目的requirements.txt文件,pip升级:pip install --upgrade setuptools | | pip install --upgrade pip | pip升级| | pip install --upgrade setuptools | setuptools 版本升级| | pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple | 使用清华镜像加速 | ## pycharm 设置环境 - 打开pycharm的Preferences - 输入Project Interpreter进行搜索 - 设置Project Interpreter路径为对应虚拟环境位置 ## 安装加速 | 附加参数 | 说明 | | -------------------- | -------------------------- | | -i https://pypi.tuna.tsinghua.edu.cn/simple | 使用清华镜像 | | -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com | 使用豆瓣镜像 | ## 启动脚本 # python app.py --profile=pro ## Variables SHUTDOWN_WAIT=5 RETVAL=0 get_pid() { #lsof -i:8666 | grep -v PID | awk '{ print $2 }' | awk 'NR==1' echo `lsof -i:${PORT} | grep -v PID | awk '{ print $2 }' | awk 'NR==1'` } start() { pid=$(get_pid) if [ -n "$pid" ] then echo "$PROJECT is already running (pid: $pid)" RETVAL=0 else echo -n $"Starting $PROJECT: " umask 007 cd ${WWW_PATH} #tar -zxvf magic_test.tar.gz tar -zxvf ${FILE_NAME} #cd magic cd ${PROJECT} python app.py & # Check pid exist pid=$(get_pid) if [ -n "$pid" ];then success RETVAL=0 else failure RETVAL=1 fi echo fi return $RETVAL } stop() { pid=$(get_pid) if [ -n "$pid" ];then echo -n $"Stopping $PROJECT: " kill -9 $pid let kwait=$SHUTDOWN_WAIT count=0; until [ `ps -p $pid | grep -c $pid` = '0' ] || [ $count -gt $kwait ] do echo -n "."; sleep 1 let count=$count+1; done if [ $count -gt $kwait ] then failure echo echo -n "Force killing $PROJECT which didn't stop after $SHUTDOWN_WAIT seconds" kill -9 $pid fi success echo else echo "$PROJECT is not running" fi return 0 } case $1 in start) start ;; stop) stop ;; restart) stop start ;; status) pid=$(get_pid) if [ -n "$pid" ] then echo "$PROJECT is running with pid: $pid" else echo "$PROJECT is not running" RETVAL=1 fi ;; *) echo "Usage: {start|stop|restart|status}" RETVAL=1 esac exit $RETVAL ```