Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

/etc/init.d/myappname start gives "Failed to start"

/var/log/appname.log tells

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

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

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

whats going wrong here?

EDIT:

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]"
}
like image 409
Sasi Kathimanda Avatar asked Mar 07 '16 12:03

Sasi Kathimanda


1 Answers

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

  1. Copy your app to /var/appname/appname.jar

  2. Make sure it's given execute permission:

    sudo chmod +x "/var/appname/appname.jar"
    
  3. Create a config file /var/appname/appname.conf with the following content

    USE_START_STOP_DAEMON=false
    
  4. Follow instructions from Spring Boot Reference Guide

    To install a Spring Boot application as an init.d service simply create a symlink:

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

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

    $ service appname start
    
like image 124
naXa Avatar answered Nov 16 '22 04:11

naXa