python -m venv venv
source venv/bin/activate
pip install -r requirements/base.txt
把_credentials.sample
后缀改为.py
并填入相关值
运行schedule.py
跑起来后配置账号里填写的邮箱会收到服务启动邮件
pip3 install supervisor
创建目录
mkdir -p ~/etc/supervisor/conf.d
mkdir -p ~/etc/supervisor/var/log
生成 supervisor 配置文件
cd ~/etc
echo_supervisord_conf > supervisord.conf
修改配置文件 supervisor.conf
[unix_http_server]
file=/home/parad1se/etc/supervisor/var/supervisor.sock ; the path to the socket file
[supervisord]
logfile=/home/parad1se/etc/supervisor/var/log/supervisord.log ; main log file; default $CWD/supervisord.log
pidfile=/home/parad1se/etc/supervisor/var/supervisord.pid ; supervisord pidfile; default supervisord.pid
user=parad1se ; setuid to this UNIX account at startup; recommended if root```
[supervisorctl]
serverurl=unix:///home/parad1se/etc/supervisor/var/supervisor.sock ; use a unix:// URL for a unix socket
[include]
files = /home/parad1se/etc/supervisor/conf.d/*.ini
注意将路径改为符合自己系统的
cd /home/parad1se/etc/supervisor/conf.d
sudo vim GZCPYHXZS.ini
粘贴并保存
[program:GZCPYHXZS]
command=python schedule.py
directory=/home/parad1se/apps/GZCPYHXZS
environment= PATH="/home/parad1se/apps/GZCPYHXZS/venv/bin/"
autostart=true
autorestart=unexpected
user=parad1se
stdout_logfile=/home/parad1se/etc/supervisor/var/log/GZCPYHXZS-stdout.log
stderr_logfile=/home/parad1se/etc/supervisor/var/log/GZCPYHXZS-stderr.log
supervisord -c ~/etc/supervisord.conf
supervisorctl -c ~/etc/supervisord.conf
supervisor>
supervisor> update
supervisor>
$ sudo yum install -y docker docker-compose
$ sudo usermod -aG docker ${USER}
$ sudo systemctl start docker
退出并重新连接服务器(这一步很重要)
如果没有配置账号,请先配置账号
在settings.py
中添加或更改ENABLE_TF_SERVING = True
使用前面supervisor安装和设置方法安装并配置, 将配置文件修改为
[program:GZCPYHXZS]
command=docker-compose -f production.yml up --build
directory=/home/parad1se/apps/GZCPYHXZS
autostart=true
autorestart=unexpected
user=parad1se
stdout_logfile=/home/parad1se/etc/supervisor/var/log/GZCPYHXZS-stdout.log
stderr_logfile=/home/parad1se/etc/supervisor/var/log/GZCPYHXZS-stderr.log
如果你已经用基本用法部署好了,现在改为docker部署,需要执行reread
和update
使配置生效
$ supervisorctl -c ~/etc/supervisord.conf
supervisor> reread
supervisor> update
重启后记得执行下面的命令启动docker和supervisor进程
$ sudo systemctl start docker
$ supervisord -c ~/etc/supervisord.conf
$ supervisorctl -c ~/etc/supervisord.conf
supervisor> status
也可以进入supervisor设置里的stdout和stderr文件查看日志
vim /home/parad1se/etc/supervisor/var/log/GZCPYHXZS-stdout.log
安装开发依赖pip install -r requirements/dev.txt
将获取到的验证码按命名格式2AHN_20210504-171258.JPEG
放在src/success_image
运行python train_my_model.py
生成的logs文件夹可用tensorboard
打开,评估训练结果
tensorboard --logdir logs