Code Monkey home page Code Monkey logo

watchlist's Introduction

watchlist

First Flask Project

tutorial: https://tutorial.helloflask.com/hello/

部署

  1. 安装python3.8或者以上版本,安装Git
yum install python38
python3 -V

yum install git
git -v
  1. 克隆项目

mkdir -p /opt/website/logs && cd /opt/website/
git clone https://github.com/dingonefly/watchlist.git
  1. 在项目根目录创建 .env 文件,写入
cd /opt/website/watchlist
vi .env

SECRET_KEY=3d6f45a5fc12445dbac2f59c3b6cwebsitex  
DATABASE_FILE=data-prod.db
  1. 新建虚拟环境
cd /opt/website/
$ python3 -m venv env  # 创建虚拟环境
$ . env/bin/activate  # 激活虚拟环境
cd /opt/website/watchlist
(env) $ pip install -r requirements.txt  # 安装所有依赖
(env) $ flask initdb  # 初始化数据库
(env) $ flask admin  # 创建管理员账户 admin/admin123
  1. 启动项目 Development
(env) [root@website watchlist]#  flask run
 * Serving Flask app 'watchlist' (lazy loading)
 * Environment: development
 * 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 http://127.0.0.1:5000
Press CTRL+C to quit
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 205-802-684

或者

ln -sf /opt/website/env/bin/gunicorn /usr/bin/gunicorn(可选)

(env) [root@website watchlist]# gunicorn -b localhost:5000 -w 4 wsgi:app

Production

(env) [root@website watchlist]#

cp ./deploykit/watchlist.service /etc/systemd/system/
systemctl daemon-reload

# 启动、查看、停止、重启
systemctl start watchlist.service
systemctl status watchlist.service
systemctl stop watchlist.service
systemctl restart watchlist.service
  1. Nginx配置
yum install nginx
mv /opt/nginx/conf.d/default.conf /opt/nginx/conf.d/default.conf.bak
mv ./deploykit/nginx_watchlist.conf /opt/nginx/conf.d/
systemctl start nginx
systemctl status nginx
  1. 项目更新
$ cd watchlist
$ git pull
  1. Q&A
  • 项目放在/home/yourname目录下,部署systemd服务的时候出现一个permission deny的错误,应该是SElinu没有关闭导致的,所以建议放在/opt/website下

watchlist's People

Contributors

dingonefly avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.