将我的应用程序符号链接到/etc/init.d/myappname后.
/etc/init.d/myappname 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]"
}
最佳答案 >将您的应用程序复制到/var/appname/appname.jar
>确保它是可执行的:
sudo chmod +x "/var/appname/appname.jar"
>使用以下内容创建配置文件/var/appname/appname.conf
USE_START_STOP_DAEMON=false
>按照Spring Boot Reference Guide的说明进行操作
To install a Spring Boot application as an init.d service simply create a symlink:
06002
Once installed, you can start and stop the service in the usual way. For example, on a Debian based system:
06003