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

推荐订阅源

SecWiki News
SecWiki News
Microsoft Azure Blog
Microsoft Azure Blog
V2EX - 技术
V2EX - 技术
N
News and Events Feed by Topic
Webroot Blog
Webroot Blog
博客园_首页
月光博客
月光博客
N
News | PayPal Newsroom
The Cloudflare Blog
博客园 - 聂微东
酷 壳 – CoolShell
酷 壳 – CoolShell
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
量子位
G
Google Developers Blog
T
Troy Hunt's Blog
博客园 - Franky
腾讯CDC
S
Security Affairs
J
Java Code Geeks
aimingoo的专栏
aimingoo的专栏
S
Security @ Cisco Blogs
www.infosecurity-magazine.com
www.infosecurity-magazine.com
The Last Watchdog
The Last Watchdog
B
Blog RSS Feed
D
DataBreaches.Net
Recorded Future
Recorded Future
H
Heimdal Security Blog
V
Vulnerabilities – Threatpost
Apple Machine Learning Research
Apple Machine Learning Research
云风的 BLOG
云风的 BLOG
博客园 - 司徒正美
D
Docker
P
Proofpoint News Feed
V
V2EX
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
S
Secure Thoughts
Engineering at Meta
Engineering at Meta
PCI Perspectives
PCI Perspectives
宝玉的分享
宝玉的分享
The Hacker News
The Hacker News
有赞技术团队
有赞技术团队
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Cloudbric
Cloudbric
Microsoft Security Blog
Microsoft Security Blog
G
GRAHAM CLULEY
MyScale Blog
MyScale Blog
L
LINUX DO - 热门话题
雷峰网
雷峰网
Know Your Adversary
Know Your Adversary

博客园 - 吾非无心

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!