zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    线程池的优雅关闭实践
    InheritableThreadLocal原理解析
    线程池踩坑
    两个线程通讯(生产-卖面包问题)
    谈谈redis的热key问题如何解决
    中国软件杯选题A1数据智能分析报告系统
    《程序员的思维修炼》读后感
    《算法导论》读后感
    《重构》读后感
    《代码整洁之道》读后感
  • 原文地址:https://www.cnblogs.com/yangyangming/p/15673421.html
Copyright © 2011-2022 走看看