我在Ubuntu 16.04虚拟机上有一个本地neo4j-community-3.5.6
目录和一个数据库。
我想在启动时启动此服务,所以我在neo4j
中创建了一个/etc/init.d
脚本并将其符号链接到目录/etc/rcS.d
如果启动脚本如下:
./home/my_user/custom_folder/neo4j-community-3.5.6/bin/neo4j start
该服务正常启动,我可以从本地网络访问它。
但是,如果我修改neo4j社区发布的默认/etc/init.d
脚本,如下所示:
#!/bin/sh
### BEGIN REDHAT INFO
# chkconfig: 2345 99 20
# description: Neo4j Graph Database server
### END REDHAT INFO
### BEGIN INIT INFO
# Provides: neo4j
# Required-Start: $remote_fs $syslog $network
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Neo4j Graph Database server
# Description: Neo4j is a Graph Database, which is a compelling
# alternative to an RDBMS. http://www.neo4j.org
### END INIT INFO
# Author: Julian Simpson <julian.simpson@neotechnology.com>
#
# Copyright (c) 2002-2018 "Neo Technology,"
# Network Engine for Objects in Lund AB [http://neotechnology.com]
#
# This file is part of Neo4j.
#
# Neo4j is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
PATH=/sbin:/usr/sbin:/bin:/usr/bin
NAME=neo4j
DAEMON=/home/my_user/custom_folder/neo4j-community-3.5.6/bin/${NAME}
PIDDIR=/var/run/${NAME}
PIDFILE=${PIDDIR}/neo4j.pid
SCRIPTNAME=/etc/init.d/${NAME}
[ -x "$DAEMON" ] || exit 0
[ -r /etc/default/${NAME} ] && . /etc/default/${NAME}
[ -n "${NEO_USER}" ] || NEO_USER=${NAME}
# Debian distros and SUSE
has_lsb_init()
{
test -f "/lib/lsb/init-functions" && [ $(grep -c status_of_proc /lib/lsb/init-functions) -gt 0 ] && [ $(grep -c start-stop-daemon /lib/lsb/init-functions) -gt 0 ]
}
# RedHat/Centos distros
has_init()
{
test -f "/etc/init.d/functions"
}
if has_lsb_init ; then
. /lib/lsb/init-functions
elif has_init ; then
. /etc/init.d/functions
else
echo "Error: your platform is not supported by ${NAME}" >&2
exit 1
fi
do_start()
{
do_ulimit
[ -d "${PIDDIR}" ] || mkdir -p "${PIDDIR}"
chown "${NEO_USER}:" "${PIDDIR}"
if has_lsb_init ; then
start-stop-daemon --chuid ${NEO_USER} --start --quiet --oknodo --pidfile ${PIDFILE} --exec ${DAEMON} -- start
else
daemon --user="${NEO_USER}" --pidfile="${PIDFILE}" "${DAEMON} start > /dev/null 2>&1 &"
fi
}
do_stop()
{
${DAEMON} stop
}
do_status()
{
if has_lsb_init ; then
status_of_proc -p "${PIDFILE}" "${DAEMON}" "${NAME}"
else
status -p "${PIDFILE}" "${NAME}"
fi
}
do_ulimit()
{
if [ -n "${NEO4J_ULIMIT_NOFILE}" ]; then
ulimit -n "${NEO4J_ULIMIT_NOFILE}"
fi
}
case "$1" in
start)
do_start
;;
stop)
do_stop
;;
status)
do_status
;;
restart|force-reload)
do_stop && do_start
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
exit 3
;;
esac
该服务无法启动,甚至尝试sudo service neo4j start
。查看建议的journalctl -xe
输出,我注意到此权限错误:
Jul 04 14:42:14 my-machine neo4j [3155]: /home/my_user/custom_folder/neo4j-community-3.5.6/bin/neo4j:第450行: /home/my_user/custom_folder/neo4j-community-3.5.6/logs/neo4j.log: 权限被拒绝
我查看了/etc/init.d
中文件的权限,它们对我来说看起来不错。由于从第一种情况开始启动服务,因此我认为这也不是文件/home/my_user/custom_folder/neo4j-community-3.5.6/bin/neo4j的问题。
什么原因导致此问题?