Linux-screen
问题:uwsgi部署flask项目,xshell关闭后,flask项目接口访问不到
解决:使用会话技术
安装会话
yum install screen
创建会话,name为会化名,创建后会跳转到会话,在此会话中启动项目
screen -S name
(torchcu11) [bosszyl@localhost ier-project]$ uwsgi --ini uwsgi-config.ini
[uWSGI] getting INI configuration from uwsgi-config.ini
*** Starting uWSGI 2.0.19.1 (64bit) on [Fri Jun 10 16:52:09 2022] ***
compiled with version: 4.8.5 20150623 (Red Hat 4.8.5-39) on 04 September 2020 07:12:10
os: Linux-3.10.0-1127.19.1.el7.x86_64 #1 SMP Tue Aug 25 17:23:54 UTC 2020
nodename: localhost.localdomain
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 36
current working directory: /home/bosszyl/ier-project
*** running under screen session 44572.ier ***
detected binary path: /root/anaconda3/envs/torchcu11/bin/uwsgi
chdir() to /home/bosszyl/ier-project/
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 4096
your memory page size is 4096 bytes
detected max file descriptor number: 65536
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uWSGI http bound on 0.0.0.0:6060 fd 4
spawned uWSGI http 1 (pid: 44719)
uwsgi socket 0 bound to TCP address 127.0.0.1:38556 (port auto-assigned) fd 3
Python version: 3.6.10 |Anaconda, Inc.| (default, Jan 7 2020, 21:14:29) [GCC 7.3.0]
Set PythonHome to /root/anaconda3/envs/torchcu11
Python main interpreter initialized at 0x253eef0
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 333504 bytes (325 KB) for 8 cores
*** Operational MODE: preforking+threaded ***
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x253eef0 pid: 44718 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (pid: 44718, cores: 2)
spawned uWSGI worker 2 (pid: 44732, cores: 2)
spawned uWSGI worker 3 (pid: 44733, cores: 2)
spawned uWSGI worker 4 (pid: 44735, cores: 2)
查看会话
screen -ls
(base) [bosszyl@localhost ~]$ screen -ls
There is a screen on:
44572.ier (Attached)
1 Socket in /var/run/screen/S-bosszyl.
重新发布项目,执行以下命令后进入会话,即当前项目的访问情况,如需重新发布项目则重启
screen -r name
关闭会话
screen -S 会话号 -X quit