• ubuntu16.04 springboot 断电后重启:程序自动重启 | ubuntu18.04 LTS 版本配置固定ip地址


    昨天客户现场说我的程序web页面404了。

    我的答复是网络不通;

    今天上午客户反映网络是通的,但是程序访问不了 

    客户把部署的服务器ip弄错了,并且服务器断电重启了。我的程序没有重启。

    nginx  springboot  程序没有自动重启【我现场重启,需要配置程序随着服务器开机自动启动】

    nginx 配置

    1. 配置nginx 自动启动
    
    vim /usr/lib/systemd/system/nginx.service
    
    [Unit]
    Description=nginx - high performance web server
    After=network.target remote-fs.target nss-lookup.target
    [Service]
    Type=forking
    ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
    ExecReload=/usr/local/nginx/sbin/nginx -s reload
    ExecStop=/usr/local/nginx/sbin/nginx -s stop
    [Install]
    WantedBy=multi-user.target
    2. 设置为自启动 systemctl enable nginx.service

     

    springboot 配置 

    1. 创建启动脚本,并授权
    
    sudo vim /etc/init.d/fw.sh
    
    #!/bin/sh
    sudo -u sense  
    java -jar /home/sense /fw/fwapp-1.2.jar > /var/log/fwapp.log  2>&1 &
    
    说明: sudo -u sense 表示我按照sense用户执行(我的文件存储在{user.dir} 即就是home/sense)
    
    授权
    chmod 755 /etc/init.d/fw.sh
    
    2. 添加到/etc/init.d/fw.sh  rc.local中
    
    sudo vim /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.
    #
    # By default this script does nothing.
    /bin/sh /etc/init.d/fw.sh
    
    exit 0
    
    3.  /etc/rc.local 添加到/etc/profile 中,开机重启,加载此文件;加载 /etc/rc.local,执行/bin/sh /etc/init.d/fw.sh
    
    sudo vim /etc/profile
    
     /etc/rc.local 
    
    执行 source /etc/profile 
    
    4. sudo reboot  重启。
    netstat -tunlp 查看nginx 端口 springboot 端口。nginx 和springboot 都正常启动了。
    

    终于世界和平了。周五了,注意身体。

    ubuntu18.04 LTS 版本配置固定ip地址
    
    testsrv@xyzl-BKHLXX1:~$ cat /etc/netplan/01-network-manager-all.yaml 
    cat: /etc/netplan/01-network-manager-all.yaml: Permission denied
    testsrv@xyzl-BKHLXX1:~$ sudo cat /etc/netplan/01-network-manager-all.yaml 
    [sudo] password for testsrv: 
    # Let NetworkManager manage all devices on this system
    network:
      version: 2
      #renderer: NetworkManager
    
      ethernets:
        enp3s0:   #配置的网卡名称
            dhcp4: no    #dhcp4关闭
            dhcp6: no    #dhcp6关闭
            addresses: [192.168.205.60/24]   #设置本机IP及掩码
            gateway4: 192.168.205.254   #设置网关
            nameservers:
                addresses: [114.114.114.114, 8.8.8.8]   #设置DNS  
    testsrv@xyzl-BKHLXX1:~$ sudo netplan apply
    

      

  • 相关阅读:
    HDU 3068 Manacher
    HDU 6188最小费用流
    Codeforces Round #442 (Div. 2) Danil and a Part-time Job
    并查集
    HDU 5988最小网络流(浮点数)
    HOJ
    HOJ
    POJ
    POJ
    关于async
  • 原文地址:https://www.cnblogs.com/xhzd/p/11959409.html
Copyright © 2020-2023  润新知