最新消息:20210917 已从crifan.com换到crifan.org

【已解决】部署绘本查询系统到线上服务器

查询 crifan 511浏览 0评论
现在已完成基本的版本的绘本查询系统了。
现在要去把Flask后台代码和前端web页面部署到在线环境。
先去上传代码到服务器端:
[root@xxx-general-01 server]# pwd
/root/xxx_20180101/web/server
[root@xxx-general-01 server]# ll
total 20
drwxr-xr-x  3 root root 4096 Oct 30 13:58 for_backup_mongodb
drwxr-xr-x  2 root root 4096 Jul 25 09:53 for_bacup_mysql
drwxr-xr-x  8 root root 4096 Jul 31 11:36 xxx
srwxrwxrwx  1 root root    0 Aug 30 15:48 xxx.sock
drwxr-xr-x 10 root root 4096 Aug 30 15:42 robotDemo
drwxr-xr-x  2 root root 4096 Oct 31 19:54 xxx
[root@xxx-general-01 server]# git clone
 
https://gitee.com/xxx_tech/xxx.git
Cloning into 'xxx'...
remote: Enumerating objects: 170, done.
remote: Counting objects: 100% (170/170), done.
remote: Compressing objects: 100% (163/163), done.
remote: Total 170 (delta 68), reused 0 (delta 0)
Receiving objects: 100% (170/170), 45.83 KiB | 0 bytes/s, done.
Resolving deltas: 100% (68/68), done.
[root@xxx-general-01 server]# ls xxx/
app.py  common  conf  deploy  factory.py  Pipfile  processData  README.md  resources
[root@xxx-general-01 server]# ll xxx/
total 48
-rw-r--r-- 1 root root  1360 Oct 31 20:06 app.py
drwxr-xr-x 2 root root  4096 Oct 31 20:06 common
drwxr-xr-x 5 root root  4096 Oct 31 20:06 conf
drwxr-xr-x 2 root root  4096 Oct 31 20:06 deploy
-rw-r--r-- 1 root root  3102 Oct 31 20:06 factory.py
-rw-r--r-- 1 root root   415 Oct 31 20:06 Pipfile
drwxr-xr-x 4 root root  4096 Oct 31 20:06 processData
-rw-r--r-- 1 root root 13656 Oct 31 20:06 README.md
drwxr-xr-x 2 root root  4096 Oct 31 20:06 resources
[root@xxx-general-01 server]#
去恢复pipenv虚拟环境:
[root@xxx-general-01 xxx]# pipenv install
Creating a virtualenv for this project…
Using /root/miniconda3/bin/python3.6m (3.6.5) to create virtualenv…
⠋Running virtualenv with interpreter /root/miniconda3/bin/python3.6m
Using base prefix '/root/miniconda3'
New python executable in /root/.local/share/virtualenvs/xxx-se4mevDU/bin/python3.6m
Also creating executable in /root/.local/share/virtualenvs/xxx-se4mevDU/bin/python
Please make sure you remove any previous custom paths from your /root/.pydistutils.cfg file.
Installing setuptools, pip, wheel...done.

Virtualenv location: /root/.local/share/virtualenvs/xxx-se4mevDU
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Updated Pipfile.lock (54f1f4)!
Installing dependencies from Pipfile.lock (54f1f4)…
   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 38/38 — 00:00:19
To activate this project's virtualenv, run the following:
$ pipenv shell
[root@xxx-general-01 xxx]# pipenv shell
Spawning environment shell (/bin/bash). Use 'exit' to leave.
[root@xxx-general-01 xxx]# . /root/.local/share/virtualenvs/xxx-se4mevDU/bin/activate
(xxx-se4mevDU) [root@xxx-general-01 xxx]# which python
/root/.local/share/virtualenvs/xxx-se4mevDU/bin/python
(xxx-se4mevDU) [root@xxx-general-01 xxx]# python --version
Python 3.6.5 :: Anaconda, Inc.
然后去服务器中,找到supervisor的配置文件下载下来:
[root@xxx-general-01 xxx]# sz /etc/supervisord.d/supervisord_server.conf
rz
Starting zmodem transfer.  Press Ctrl+C to cancel.
Transferring supervisord_server.conf...
  100%       2 KB       2 KB/sec    00:00:01       0 Errors  
去编辑,加上当前项目,且python解析器改为上面的新的:
command=/root/.local/share/virtualenvs/xxx-se4mevDU/bin/gunicorn -c conf/gunicorn/gunicorn_config.py app:app
environment = FLASK_ENV="production"
directory=/root/xxx_20180101/web/server/xxx
startsecs=0
stopwaitsecs=0
autostart=true
autorestart=true
killasgroup=true
stopasgroup=true

stdout_logfile=/root/xxx_20180101/web/server/xxx/logs/supervisord-%(program_name)s-stdout.log
stdout_logfile_maxbytes=2MB
stdout_logfile_backups=10

stderr_logfile=/root/xxx_20180101/web/server/xxx/logs/supervisord-%(program_name)s-stderr.log
stderr_logfile_maxbytes=2MB
stderr_logfile_backups=10
然后传上去
(xxx-se4mevDU) [root@xxx-general-01 xxx]# git pull
remote: Enumerating objects: 9, done.
remote: Counting objects: 100% (9/9), done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 5 (delta 4), reused 0 (delta 0)
Unpacking objects: 100% (5/5), done.
From
 
https://gitee.com/xxx_tech/xxx
   a873d74..7d0cca4  master     -> origin/master
Updating a873d74..7d0cca4
Fast-forward
conf/supervisor/supervisord_server.conf | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
覆盖系统配置:
(xxx-se4mevDU) [root@xxx-general-01 xxx]# cp -f conf/supervisor/supervisord_server.conf /etc/supervisord.d/supervisord_server.conf
cp: overwrite ‘/etc/supervisord.d/supervisord_server.conf’? y
然后重启服务:
(xxx-se4mevDU) [root@xxx-general-01 xxx]# supervisorctl stop all   
xxx: stopped
robotDemo: stopped
robotDemo_CeleryBeat: stopped
redis: stopped
robotDemo_CeleryWorker: stopped
(xxx-se4mevDU) [root@xxx-general-01 xxx]# supervisorctl reload   
Restarted supervisord
(xxx-se4mevDU) [root@xxx-general-01 xxx]# supervisorctl start all
gunicorn: started
(xxx-se4mevDU) [root@xxx-general-01 xxx]#
去看看是否正常运行了。
结果postman测试api超时。
想到了,需要去阿里云安全组中开通这个端口:
然后就可以了:
另外再去把web页面放到服务器中
(xxx-se4mevDU) [root@xxx-general-01 www]# git clone
 
https://gitee.com/xxx_tech/xxxWeb.git
Cloning into 'xxxWeb'...
remote: Enumerating objects: 47, done.
remote: Counting objects: 100% (47/47), done.
remote: Compressing objects: 100% (46/46), done.
remote: Total 47 (delta 11), reused 0 (delta 0)
Unpacking objects: 100% (47/47), done.
(xxx-se4mevDU) [root@xxx-general-01 www]# ll
total 1094880
-rwxr-xr-x 1 root root       3650 May  2 15:56 404.html
-rwxr-xr-x 1 root root       3693 May  2 15:56 50x.html
-rw-r--r-- 1 root root      25838 Jul 10 11:36 favicon.jpg
-rw-r--r-- 1 root root       6716 Jun 24 11:07 favicon.png
-rw-r--r-- 1 root root 1121079991 Aug 15 18:18 glove_6b.7z
-rw-r--r-- 1 root root       3700 Jun 24 15:15 index.html
drwxr-xr-x 8 root root       4096 Aug 11 13:23 xxxWeb
-rwxr-xr-x 1 root root        368 May  2 15:56 nginx-logo.png
-rwxr-xr-x 1 root root       2811 May  2 15:56 poweredby.png
drwxrwxrwx 8 root root       4096 May 28 17:39 robotDemo
drwxr-xr-x 6 root root       4096 Oct 31 20:49 xxxWeb
(xxx-se4mevDU) [root@xxx-general-01 www]# cd xxxWeb/
(xxx-se4mevDU) [root@xxx-general-01 xxxWeb]# ll
total 28
-rw-r--r-- 1 root root 2406 Oct 31 20:49 book_detail.html
drwxr-xr-x 4 root root 4096 Oct 31 20:49 css
drwxr-xr-x 2 root root 4096 Oct 31 20:49 img
-rw-r--r-- 1 root root 4993 Oct 31 20:49 index.html
drwxr-xr-x 4 root root 4096 Oct 31 20:49 js
-rw-r--r-- 1 root root  269 Oct 31 20:49 README.md
(xxx-se4mevDU) [root@xxx-general-01 xxxWeb]# pwd
/root/xxx_20180101/web/www/xxxWeb
以及后续更新代码:
(xxx-se4mevDU) [root@xxx-general-01 xxxWeb]# git pull
remote: Enumerating objects: 21, done.
remote: Counting objects: 100% (21/21), done.
remote: Compressing objects: 100% (11/11), done.
remote: Total 11 (delta 8), reused 0 (delta 0)
Unpacking objects: 100% (11/11), done.
From
 
https://gitee.com/xxx_tech/xxxWeb
   64ad8b8..fa01cb3  master     -> origin/master
Updating 64ad8b8..fa01cb3
Fast-forward
README.md           |   4 +++
book_detail.html    |  13 +++++----
css/book_detail.css |   7 +++++
css/main.css        |   8 ++++++
index.html          |  32 ++++++++++-----------
js/book_detail.js   | 244 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------------------------------
js/main.js          | 122 +++++++++++++++++++++++++++++++++++++++++++++++--------------------------------
7 files changed, 305 insertions(+), 125 deletions(-)
(xxx-se4mevDU) [root@xxx-general-01 xxxWeb]#
就可以看到页面了:
然后后面就是去优化代码的事情了。

转载请注明:在路上 » 【已解决】部署绘本查询系统到线上服务器

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
94 queries in 0.196 seconds, using 23.37MB memory