复制代码
cd  /etc/systemd/system

sudo vim startdjango.service:

[Unit]
Description=It is startdjango

[Service]
Type=simple
ExecStart=/home/ubuntu/.myenv/myfirst/bin/python /home/ubuntu/mymnt/project/myproject/wanwenyc/manage.py runserver 0.0.0.0:8000
#启动失败之后重启
Restart=on-failure
#重启间隔为5s
RestartSec=5s

[Install]
WantedBy=multi-user.target

复制代码

然后 

sudo systemctl enable startdjango  :注册服务

sudo systemctl start startdjango :注册服务

 

sudo service startdjango status  :查看startdjango 服务启动状态

posted on 2022-02-21 20:14  大话人生  阅读(293)  评论(0编辑  收藏  举报