1.首先写一个shell脚本,启动uwsgi
脚本内容参考如下:
bash:#!/bin/bash
source /home/urun/web/py3env/bin/activate # 进入python独立环境
cd /home/urun/web/YunrunClusterManager/ # 进入程序路径
nohup /home/urun/web/py3env/bin/uwsgi uwsgi.ini & # 执行uwsgi,注意需要用uwsgi独立环境的绝对路径
2.验证脚本正常后,在/etc/rc.local加上执行脚本的命令,参考如下:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
sudo sh /opt/restart.sh
exit 0
注意修改成你自己的sh脚本路径