zoukankan      html  css  js  c++  java
  • Centos7创建systemctl服务

    1. 创建服务配置文件

    [root@localhost ~]# cat /etc/systemd/system/test.service
    [Unit]
    Description=test Service
    After=syslog.target
    
    [Service]
    User=root
    ExecStart=/home/test/current/app.jar
    SuccessExitStatus=143
    
    [Install]
    WantedBy=multi-user.target

    2. 配置介质包启动文件

    [root@localhost test]# cat shared/config/app.conf 
    # --------------------------------------------------------------------------
    # The “mode” of operation. The default depends on the way the jar was built,
    # but will usually be auto (meaning it tries to guess if it is an init script by checking
    # if it is a symlink in a directory called init.d).
    # You can explicitly set it to service so that the stop|start|status|restart commands work,
    # or to run if you just want to run the script in the foreground.
    # --------------------------------------------------------------------------
    # MODE=
    
    # --------------------------------------------------------------------------
    # If the start-stop-daemon command, when it’s available, should be used to control the process.
    # Defaults to true.
    # --------------------------------------------------------------------------
    # USE_START_STOP_DAEMON=
    
    # --------------------------------------------------------------------------
    # The root name of the pid folder (/var/run by default).
    # --------------------------------------------------------------------------
    # PID_FOLDER=
    
    # --------------------------------------------------------------------------
    # The name of the folder to put log files in (/var/log by default).
    # --------------------------------------------------------------------------
    #LOG_FOLDER=/home/ckettle/schedule/shared/logs
    
    # --------------------------------------------------------------------------
    # The name of the log file in the LOG_FOLDER (<appname>.log by default).
    # --------------------------------------------------------------------------
    # LOG_FILENAME=
    
    # --------------------------------------------------------------------------
    # The name of the app. If the jar is run from a symlink the script guesses the app name,
    # but if it is not a symlink, or you want to explicitly set the app name this can be useful.
    # --------------------------------------------------------------------------
    # APP_NAME=
    
    # --------------------------------------------------------------------------
    # The arguments to pass to the program (the Spring Boot app).
    # --------------------------------------------------------------------------
    RUN_ARGS="--spring.pid.file=/home/test/shared/tmp/application.pid --spring.config.location=file:/home/test/shared/config/ --spring.profiles.active=test"
    
    # --------------------------------------------------------------------------
    # The location of the java executable is discovered by using the PATH by default,
    # but you can set it explicitly if there is an executable file at $JAVA_HOME/bin/java.
    # --------------------------------------------------------------------------
    JAVA_HOME=/usr/local/java/jdk1.8.0_11
    
    # --------------------------------------------------------------------------
    # Options that are passed to the JVM when it is launched.
    # --------------------------------------------------------------------------
    # JAVA_OPTS=
    
    # --------------------------------------------------------------------------
    # The explicit location of the jar file,
    # in case the script is being used to launch a jar that it is not actually embedded in.
    # --------------------------------------------------------------------------
    # JARFILE=
    
    # --------------------------------------------------------------------------
    # if not empty will set the -x flag on the shell process, making it easy to see the logic in the script.
    # --------------------------------------------------------------------------
    # DEBUG=

    3. 介质包赋权

    chmod u+x /home/test/current/app.jar

    4. 控制介质包

    systemctl status/restart/start/stop test.service
  • 相关阅读:
    IDEA(jetbrain通用)优雅级使用教程(转)
    intellij idea 修改背景保护色&&修改字体&&快捷键大全(转)
    淘宝可伸缩高性能互联网架构HSF(转)
    spring利用注解@Value获取properties属性为null
    String.valueOf()方法注意
    Spring任务调度器之Task的使用(转)
    Mybatis集成(转)
    深入理解mybatis原理, Mybatis初始化SqlSessionFactory机制详解(转)
    Spring+Mybatis+SpringMVC+Maven+MySql搭建实例(转)
    Spring4.2+SpringMVC+Mybatis3.4的集成(转-)
  • 原文地址:https://www.cnblogs.com/cpw6/p/13216233.html
Copyright © 2011-2022 走看看