ubuntu18.04设置开机自启Django
2021/12/11 7:19:21
本文主要是介绍ubuntu18.04设置开机自启Django,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
设置开机自启:
rc-local.server
[Unit] Description=/etc/rc.local Compatibility ConditionPathExists=/etc/rc.local After=network.target After=postgresql.service [Service] Type=forking ExecStart=/etc/rc.local start TimeoutSec=0 StandardOutput=tty RemainAfterExit=yes SysVStartPriority=99 [Install] WantedBy=multi-user.target
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. # # By default this script does nothing. echo "start django manage..." > /root/start_django_manage.log a=`lsof -i:5432 | wc -l` echo "$a" >> /root/start_django_manage.log if [ "$a" > "0" ];then echo "start psql" >> /root/start_django_manage.log cd /opt/soft/dist/manage/ ./manage runserver 0.0.0.0:80 >> ./log/logs.log 2>&1 & else echo "waiting......" >> /root/start_django_manage.log fi echo "end..." >> /root/start_django_manage.log exit 0
1、cp ./rc-local.server /etc/systemd/system/
cp ./rc.local /etc/
2、
cd /etc/systemd/system/
chmod +x /etc/rc.local
systemctl enable rc-local.service
systemctl start rc-local.service
systemctl status rc-local.service
这篇关于ubuntu18.04设置开机自启Django的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-10-012024年每个初学者都应该知道的Django十大技巧
- 2024-09-30云原生周刊:Argo CD v2.13 发布候选版本丨2024.9.30
- 2024-09-29哪个更快:OpenAI Whisper、Google TTS 还是 Piper TTS??
- 2024-09-29MLOps 端到端系统在 Google 云平台(I):赋能预测解决方案
- 2024-09-26通过 gcloud CLI 认证从本地脚本写入 Google Sheets
- 2024-09-24GoLand 新建项目 Enable vendoring support automatically 的作用是什么?-icode9专业技术文章分享
- 2024-09-21MongoDB资料:新手入门与初级应用指南
- 2024-09-20MongoDB教程:初学者必备指南
- 2024-09-05MongoDB入门:快速掌握NoSQL数据库基础
- 2024-08-28go 项目中怎么打印调试-icode9专业技术文章分享