#!/sbin/openrc-run

description="A highly scalable, robust native graph database"

: ${cfgdir:="/etc/neo4j"}
: ${homedir:="/var/lib/neo4j"}
: ${command_user:="neo4j"}
: ${retry="TERM/30/KILL/5"}
: ${rc_ulimit="-n 40000"}
: ${start_wait:=1000}  # milliseconds

command="/usr/bin/neo4j"
command_args="console $command_args"
command_background="yes"
directory="$homedir"
pidfile="/run/$RC_SVCNAME.pid"

start_stop_daemon_args="--wait $start_wait $start_stop_daemon_args"
# The leading space is to avoid fallback to $start_stop_daemon_args when this
# is empty (supervise-daemon doesn't support --wait).
supervise_daemon_args=" $supervise_daemon_args"

depend() {
	need localmount net
	after firewall
}

start_pre() {
	export NEO4J_CONF="$cfgdir"
	export NEO4J_HOME="$homedir"

	# Neo4j writes its own pid file into this directory.
	checkpath -d -q -m700 -o "$command_user" /run/neo4j
}
