惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
Microsoft Security Blog
Microsoft Security Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
V
Visual Studio Blog
宝玉的分享
宝玉的分享
IT之家
IT之家
人人都是产品经理
人人都是产品经理
T
The Blog of Author Tim Ferriss
I
InfoQ
B
Blog RSS Feed
T
Threatpost
博客园_首页
M
MIT News - Artificial intelligence
Spread Privacy
Spread Privacy
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Know Your Adversary
Know Your Adversary
U
Unit 42
Engineering at Meta
Engineering at Meta
C
Cyber Attacks, Cyber Crime and Cyber Security
月光博客
月光博客
Scott Helme
Scott Helme
T
Tor Project blog
有赞技术团队
有赞技术团队
AWS News Blog
AWS News Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Last Week in AI
Last Week in AI
S
Schneier on Security
Vercel News
Vercel News
博客园 - Franky
C
Cybersecurity and Infrastructure Security Agency CISA
L
LINUX DO - 热门话题
NISL@THU
NISL@THU
L
LangChain Blog
爱范儿
爱范儿
Google DeepMind News
Google DeepMind News
The GitHub Blog
The GitHub Blog
雷峰网
雷峰网
Latest news
Latest news
C
CXSECURITY Database RSS Feed - CXSecurity.com
Hugging Face - Blog
Hugging Face - Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
G
GRAHAM CLULEY
S
Security Affairs
A
About on SuperTechFans
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
大猫的无限游戏
大猫的无限游戏
W
WeLiveSecurity
Cisco Talos Blog
Cisco Talos Blog
罗磊的独立博客

博客园 - 吾非无心

MSB4019 找不到导入的项目“C:\Users\...\AppData\Local\QtMsBuild\vs-debugtools\qt_import.props” - 吾非无心 - 博客园 类/结构最后一个成员为类(string)时可能会出现“堆损坏”(HEAP CORRUPTION DETECTED)错误 GCC在C语言中内嵌汇编 asm __volatile__ QT删除python中的单行注释 double转int QJson 存储(u)longlong有问题 QT QPixmap QImage内存泄漏 QMetaObject::connectSlotsByName: No matching signal for QT数据库连接管理类 QT多重继承带来的问题及解决办法,记录备查 QT6 源码编译Win32 x86 vc++高精度计时sleep stack smashing detected 莫名其妙的错误 strdump的问题 再加一个realloc的问题 linux下简单封装读写锁 codeblocks下libacl配置 centos8 安装、配置redis6 pyftpdlib中文乱码的解决之道 libevent学习一
CentOS8让uwsgi开机自动启动django(无需登录,无需手动)
吾非无心 · 2020-09-11 · via 博客园 - 吾非无心

baidu了好几天,折腾了好几天,终于让uwsgi能在CentOS8下开机自动启动Django网站了

网上说的:

/etc/init.d/???.sh

chkconfig --add ???.sh

这种↑方法,不行!!

没研究,不知道是不是CentOS8版本原因

今天看了下Systemd的介绍,终于以.service的方式搞定。

解决方案分两步:

  1、新建自己的 xxx.service(位置:/etc/systemd/system)

[Unit]
Description=uwsgi-xxx-support
After=network.target
Before=nginx.service

[Service]
ExecStart=/usr/sbin/xxx.sh
ExecReload=/bin/kill -HUP ( ps -ep | grep uwsgi)
Type=forking


[Install]
WantedBy=multi-user.target
~                              

注意:: Type 要设置为forking,因为xxx.sh执行完之后是要退出的,继续运行的是uwsgi进程,默认的simple是启动不了的,状态会一直是inactive(dead)

建 好 之 后:$  systemctl enable xxx.service

  2、建自己的xxx.sh脚本(我放在/usr/sbin)

#!/bin/sh 
  
venvwrap="virtualenvwrapper.sh"



python38=`/usr/bin/which python3.8`
VIRTUALENVWRAPPER_PYTHON=${python38}

export WORKON_HOME=/root/.virtualenvs

if [ $? -eq 0 ]; then
        venvwrap=`/usr/bin/which $venvwrap`
        source $venvwrap
fi

workon .xxx
source activate
uwsgi --ini /webroot/xxx/uwsgi.ini &
~                                                                                                                                             
~                                                                                                                                             
~                                                                                                                                             
~          

     要设置 VIRTUALENVWRAPPER_PYTHON          ,否则source ...../virtualenvwrapper.sh会报错,报找不到python

     要export WORKON_HOME    ,否则workon找不到虚拟环境

     activate要以source 参数的形式运行,否则报无权限

      uwsgi  最后添&,表示后台执行

 reboot

不登录,不执行任何指令

打开浏览器,浏览网站

SUCCESS!