ubuntu系统添加开机自动启动django


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 服务启动状态