簡體   English   中英

spring boot init.d腳本啟動停止守護程序:無法識別的選項--no-close

[英]spring boot init.d script start-stop-daemon: unrecognized option --no-close

在將我的應用程序符號鏈接到/etc/init.d/myappname 之后

/etc/init.d/myappname start 給出"Failed to start"

/var/log/appname.log告訴

"start-stop-daemon: unrecognized option '--no-close'"

當我刪除--no-close ,jar 會損壞並且無法再運行。 我很震驚。

bdw 我的 jar 是完全可執行的 jar。 即,當我單獨運行 jar 時,它會正常啟動 springboot。

這里出了什么問題?

編輯:

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]"
}

我假設你已經為你的 Spring Boot 應用程序創建了一個可執行的 JAR

  1. 將您的應用復制到/var/appname/appname.jar

  2. 確保它具有執行權限

     sudo chmod +x "/var/appname/appname.jar"
  3. 使用以下內容創建配置文件/var/appname/appname.conf

     USE_START_STOP_DAEMON=false
  4. 按照Spring Boot 參考指南中的說明進行操作

    要將 Spring Boot 應用程序安裝為 init.d 服務,只需創建一個符號鏈接:

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

    安裝后,您可以按照通常的方式啟動和停止服務。 例如,在基於 Debian 的系統上:

     $ service appname start

我終於解決了這個問題。

--no-close是“最近”添加到 start-stop-daemon 的參數

http://manpages.ubuntu.com/manpages/wily/man8/start-stop-daemon.8.html

我在 Ubuntu 12.04 LTS 上運行我的 app.jar,它有 Debian 的 start-stop-daemon 1.16.1.2

你可以知道你正在使用什么版本:

start-stop-daemon --version

在 linux 控制台上。

我下載了更新版本的 start-stop-daemon

https://pkgs.org/ubuntu-14.04/ubuntu-main-amd64/dpkg_1.17.5ubuntu5_amd64.deb.html

安裝 deb 包,spring boot jar 將最終運行。

運行文檔http://docs.spring.io/spring-boot/docs/current/reference/html/deployment-install.html 中提到的“service myappname start”

/etc/init.d/myappname start 和 server myappname start 有區別

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM