Front Vue, back -end FLASK
It's best to open it under Chrome, some styles of Safari have problems for the first time.
Technology stack: Vue + Vuex + Elementui + Flask + Peewee + HTTPBASICAUTH + CELERY + FABRIC (front -end and back -end separation MVVM mode)
At present, the front -end processing of cross -domain issues can be optimized into back -end processing later
Pymonitor.py can monitor the real -time changes of the Python script, simply simulate a server -side heat update function
1. 登录注册(带token,过期验证) 使用的peewee(orm)
2. CRUD服务器资源列表、测试任务列表
3. 展示测试报告(locust)
4. 上传文件到远程服务器, fabric远程操作linux命令,
Use Celery to implement distributed asynchronous tasks
celery worker -A curd.celery -l info -f celery.log
启动celery worker 更改celery配置需要重启celery
The message queue is stored in Rabbitmq or Redis (Broker middleware)
The results of the task status exist in redis (back), and the front end updates the corresponding task status according to this state
Start the front end (Vue):
需要安装node 和yarn
cd frontend
yarn run serve
Start the back end (Flask)
nohup python3 run.py >/dev/null 2>&1 &
Start Redis (not to get data without starting the report interface)
nohup redis-server > web6.log 2>&1 < /dev/null&
Install rabbitmq: (You can use it, replace it with redis)
brew install rabbitmq
cd /usr/local/Cellar/rabbitmq/3.8.2 (安装目录)
Visual monitoring plug -in installation of rabiitmq
sudo sbin/rabbitmq-plugins enable rabbitmq_management
Configure Rabbitmq environment variable
vi ~/.bash_profile
export RABBIT_HOME= /usr/local/Cellar/rabbitmq/3.8.2
export PATH=$PATH:$RABBIT_HOME/sbin
source ~/.bash_profile
Start Rabbitmq in the background
后台启动
rabbitmq-server -detached
查看状态
rabbitmqctl status
访问可视化监控插件的界面
浏览器内输入 http://localhost:15672,
默认的用户名密码都是guest,登录后可以在Admin那一列菜单内添加自己的用户
rabbitmqctl stop 关闭
Monitor the Flower
pip install flower
启动flower
celery flower --address=127.0.0.1 --port=5555
可通过浏览器查看
http://127.0.0.1:5555
Use Supervisord
pip install supervisor
在根目录下添加配置:
echo_supervisord_conf> supervisord.conf
[program:celeryd]
command=celery worker -A curd.celery -l info -f celery.log --concurrency=15
;stdout_logfile=/var/log/celery/celeryd.log
;stderr_logfile=/var/log/celery/celeryd.log
autostart=true
autorestart=true
startsecs=10
启动
supervisord
重启
supervisorctl reload
Deploy the FLASK production environment on Linux
pip install gunicorn
vim gunicorn.sh
nohup gunicorn -w 4 -b 0.0.0.0:8888 run:app > gunicorn.log 2>&1 &
sh gunicorn.sh
-w 4是指预定义的工作进程数为4,
-b 127.0.0.1:4000指绑定地址和端口
Deploy Vue (nginx)
在linux上打包得到dist
/usr/local/nginx/conf
在nginx.conf 第一行修改 user root;(解决403问题)
sudo ./nginx -s stop(reload)停止nginx(重新加载conf)
ps axu | grep nginx
nginx -t 查看具体使用那个conf -c + 路径(具体哪个conf)
Under linux, mysql Chinese garbled:
locate my.cnf
ps aux|grep mysql|grep 'my.cnf'(查看是否使用了指定目录的my.cnf)
mysql --help|grep 'my.cnf'(查看mysql默认读取my.cnf的目录, 顺序排前的优先。)
[mysqld]
character-set-server=utf8
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
show full columns from machine; 查询表的字符编码
sudo service mysqld restart (重启mysql)
show variables like 'character%'; 查看数据库的编码格式
show create database test; 查看数据库字符编码
alter database test default character set utf8 collate utf8_general_ci;
更改数据库字符编码
alter table `表名` convert to character set utf8;
一次性修改表中所有字段的字符集语句
Deploy Flask on Linux with gunicorn
touch gunicorn.sh
nohup gunicorn -w 1 -b 0.0.0.0:8888 run:app > gunicorn.log 2>&1 &