Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] 在linux deploy 的 arm安卓版本linux 中 服务启动失败 #658

Open
chendx-github opened this issue Nov 16, 2023 · 16 comments
Open
Labels

Comments

@chendx-github
Copy link

问题描述
这里输入问题描述

重现步骤
重现步骤如下:
安装服务之后启动
如下是生成的服务配置文件:
#!/sbin/openrc-run
supervisor=supervise-daemon
name="Nging"
description=""
command=/usr/sof/nging_linux_arm64/nging
command_args="service run "
name=$(basename $(readlink -f $command))
supervise_daemon_args="--stdout /var/log/${name}.log --stderr /var/log/${name}.err"

期望的正确结果
正常启动

截图
image

系统类型和版本:

  • arm 64位 linux deploy中

数据库类型和版本:

  • sqlite
@chendx-github
Copy link
Author

如果我手动运行是可以正常启动程序的

@admpub
Copy link
Owner

admpub commented Nov 16, 2023

这个系统里面有supervise吗?如果系统本身不支持服务,也可以自己编写开机自启脚本。
参考资料

@chendx-github
Copy link
Author

系统本身是支持服务的,sshd的服务都是可以正常启动
下面这个是sshd的服务
#!/sbin/openrc-run

description="OpenBSD Secure Shell server"
description_checkconfig="Verify configuration file"
description_reload="Reload configuration"

extra_commands="checkconfig"
extra_started_commands="reload"

NOTE: SSHD_* variables are deprecated and will be removed in future!

: "${sshd_disable_keygen:="${SSHD_DISABLE_KEYGEN:-"no"}"}"
: "${cfgfile:=${SSHD_CONFIG:-"${SSHD_CONFDIR:-"/etc/ssh"}/sshd_config"}}"

pidfile="${SSHD_PIDFILE:-"/run/$RC_SVCNAME.pid"}"
command="${SSHD_BINARY:-"/usr/sbin/sshd"}"
command_args="${command_args:-${SSHD_OPTS:-}}"

required_files="$cfgfile"

generate_host_key_type() {
local bit_size key_type

key_type=$1
if [ ! -f /etc/ssh/ssh_host_"${key_type}"_key ]; then
	case $key_type in
		ecdsa)	bit_size="$ecdsa_bit_size";;
		rsa)	bit_size="$rsa_bit_size";;
	esac
	einfo "Generating $key_type SSH host key..."
	ssh-keygen \
		-q \
		-f /etc/ssh/ssh_host_"$key_type"_key \
		-N '' \
		-t "$key_type" \
		${bit_size:+ -b ${bit_size}} || return 1
fi

}

generate_host_keys() {
local type

if [ -z "$key_types_to_generate" ] &&
   [ -z "$ecdsa_bit_size" ] && [ -z "$rsa_bit_size" ]; then
	ssh-keygen -A
	return
fi
for type in ${key_types_to_generate:-dsa ecdsa ed25519 rsa}; do
	generate_host_key_type "$type" || return 1
done

}

get_conf() {
awk "/^$1/{ print $2 }" "$cfgfile" 2>/dev/null
}

conf_enabled() {
[ "$(get_conf "$1")" = "yes" ]
}

depend() {
use logger dns
after entropy

if [ "${rc_need+set}" = "set" ] ; then
	: # Do nothing, the user has explicitly set rc_need
else
	local x warn_addr
	# shellcheck disable=SC2013
	for x in $(get_conf ListenAddress) ; do
		case "$x" in
			0.0.0.0|0.0.0.0:*) ;;
			::|\[::\]*) ;;
			*) warn_addr="$warn_addr $x" ;;
		esac
	done
	if [ -n "$warn_addr" ] ; then
		need net
		ewarn "You are binding an interface in ListenAddress statement in your sshd_config!"
		ewarn "You must add rc_need=\"net.FOO\" to your /etc/conf.d/sshd"
		ewarn "where FOO is the interface(s) providing the following address(es):"
		ewarn "$warn_addr"
	fi
fi

}

update_command() {
if conf_enabled KerberosAuthentication || conf_enabled GSSAPIAuthentication && [ -r /usr/sbin/sshd.krb5 ]; then
command="${SSHD_BINARY:-"/usr/sbin/sshd.krb5"}"
elif conf_enabled UsePAM && [ -r /usr/sbin/sshd.pam ]; then
command="${SSHD_BINARY:-"/usr/sbin/sshd.pam"}"
fi
}

checkconfig() {
update_command
warn_deprecated_var SSHD_BINARY
warn_deprecated_var SSHD_CONFDIR
warn_deprecated_var SSHD_CONFIG cfgfile
warn_deprecated_var SSHD_DISABLE_KEYGEN sshd_disable_keygen
warn_deprecated_var SSHD_OPTS command_args
warn_deprecated_var SSHD_PIDFILE

if [ ! -d /var/empty ] ; then
	mkdir -p /var/empty || return 1
fi

if ! yesno "$sshd_disable_keygen"; then
	generate_host_keys || return 1
fi

[ "$pidfile" != "/run/sshd.pid" ] \
	&& command_args="$command_args -o PidFile=$pidfile"

[ "$cfgfile" != "/etc/ssh/sshd_config" ] \
	&& command_args="$command_args -f $cfgfile"

# shellcheck disable=SC2086
"$command" -t $command_args || return 1

}

start_pre() {
checkconfig
}

stop_pre() {
update_command
if [ "${RC_CMD}" = "restart" ] ; then
checkconfig || return 1
fi
}

stop_post() {
if [ "$RC_RUNLEVEL" = "shutdown" ]; then
_sshd_pids=$(pgrep "${command##*/}:")
if [ -n "$_sshd_pids" ]; then
ebegin "Shutting down ssh connections"
# shellcheck disable=SC2086
kill -TERM $_sshd_pids >/dev/null 2>&1
eend 0
fi
fi
}

reload() {
checkconfig || return 1

ebegin "Reloading $RC_SVCNAME"
start-stop-daemon --signal HUP \
	--exec "$command" --pidfile "$pidfile"
eend $?

}

warn_deprecated_var() {
local varname="$1"
local replacement="${2:-}"

eval "test -n \"\$$varname\"" || return 0

ewarn "Variable \$$varname is deprecated and will be removed in the future!"
# shellcheck disable=SC2015
[ "$replacement" ] && ewarn "Use \$$replacement instead of \$$varname." ||:

}

@admpub
Copy link
Owner

admpub commented Nov 16, 2023

方便提供一下 nging 中的 data/logs/service.log 文件内容吗?

@admpub
Copy link
Owner

admpub commented Nov 16, 2023

你填写的sqlite数据库文件是不是相对路径,可以改成绝对路径试试,因为我看服务生成的配置中不支持工作目录,不知道是否与此有关

@chendx-github
Copy link
Author

我自己写服务是可以的,使用的是 执行rc.local 文件

@chendx-github
Copy link
Author

应该是相对路径这个原因 如何改为绝对路径,我没找到配置方法,还是说需要修改代码重新编译才能实现?

@admpub
Copy link
Owner

admpub commented Nov 17, 2023

确实是相对路径的问题,不支持设置工作目录的情况下就会有问题,我修复一下发布新版本

@admpub
Copy link
Owner

admpub commented Nov 29, 2023

@chendx-github 是否有升级到 v5.2.4? 这个问题还存在吗?

@chendx-github
Copy link
Author

我明天测试一下

@chendx-github
Copy link
Author

我刚刚测试,还是不行

@chendx-github
Copy link
Author

我昨天晚上又测试了,发现似乎可以启动了,只是在安装好服务之后 使用 nging service start 的时候会提示失败

@chendx-github
Copy link
Author

我刚刚猜测是 确实不行,服务无法启动

@chendx-github
Copy link
Author

老大 这个问题能解决吗

@admpub
Copy link
Owner

admpub commented Dec 26, 2023

优先级不高。最好能提供报错的具体信息。我没有这样的环境,单单失败二字无从下手。

@admpub
Copy link
Owner

admpub commented Dec 26, 2023

没有root权限的安卓手机不好排查

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants