本文介绍了spring boot init.d脚本start-stop-daemon:无法识别的选项--no-close的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将我的应用链接到/etc/init.d/myappname 之后.

after symlink my app to the /etc/init.d/myappname.

/etc/init.d/myappname 开始会给出"Failed to start"

/var/log/appname.log 告诉

当我删除--no-close时,罐子损坏,无法再运行.我被感动了.

when i remove the --no-close, the jar becomes corrupted and cannot run anymore. i am struck.

bdw我的jar是完全可执行的jar.即,当我单独运行jar时,它将正常启动springboot.

bdw my jar is fullyexecutable jar. i.e., when i run the jar alone it starts up the springboot normally.

这里出了什么问题?

do_start() {
  working_dir=$(dirname "$jarfile")
  pushd "$working_dir" > /dev/null
  if [[ -n "$run_user" ]]; then
    mkdir "$PID_FOLDER" &> /dev/null
    checkPermissions || return $?
    chown "$run_user" "$PID_FOLDER"
    chown "$run_user" "$pid_file"
    chown "$run_user" "$log_file"
    if [ $USE_START_STOP_DAEMON = true ] && type start-stop-daemon > /dev/null 2>&1; then
      arguments=(-Dsun.misc.URLClassPath.disableJarChecking=true $JAVA_OPTS -jar $jarfile $RUN_ARGS "$@")
      start-stop-daemon --start --quiet \
        --chuid "$run_user" \
        --name "$identity" \
        --make-pidfile --pidfile "$pid_file" \
        --background --no-close \
        --startas "$javaexe" \
        --chdir "$working_dir" \
        -- "${arguments[@]}" \
        >> "$log_file" 2>&1
      await_file "$pid_file"
    else
      su -s /bin/sh -c "$command >> \"$log_file\" 2>&1 & echo \$!" "$run_user" > "$pid_file"
    fi
    pid=$(cat "$pid_file")
  else
    checkPermissions || return $?
    $command >> "$log_file" 2>&1 &
    pid=$!
    disown $pid
    echo "$pid" > "$pid_file"
  fi
  [[ -z $pid ]] && { echoRed "Failed to start"; return 1; }
  echoGreen "Started [$pid]"
}

推荐答案

我假设您已经创建了一个可执行JAR 您的Spring Boot应用.

I assume you already created an executable JAR of your Spring Boot app.

  1. 将您的应用复制到/var/appname/appname.jar

确保已获得执行权限:

sudo chmod +x "/var/appname/appname.jar"

  • 创建具有以下内容的配置文件/var/appname/appname.conf

    USE_START_STOP_DAEMON=false
    

  • 遵循来自 Spring Boot参考指南

    $ sudo ln -s /var/appname/appname.jar /etc/init.d/appname
    

    安装后,您可以按照通常的方式启动和停止服务.例如,在基于Debian的系统上:

    Once installed, you can start and stop the service in the usual way. For example, on a Debian based system:

    $ service appname start
    

  • 这篇关于spring boot init.d脚本start-stop-daemon:无法识别的选项--no-close的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

    08-24 13:20