I'm trying to write a openrc init script for MongoDB following this guide. Here's what I got done so far:
#!/sbin/openrc-run
MONGOD_USER="${MONGOD_USER:-mongodb}"
MONGOD_GROUP="${MONGOD_GROUP:-mongodb}"
MONGOD_CONFIG="${MONGOD_CONFIG:-/etc/mongodb.conf}"
MONGOD_LOGFILE="${MONGOD_LOGFILE:-/var/log/mongodb/mongod.log}"
description="MongoDB service"
pidfile="/run/mongodb.pid"
supervisor=supervise-daemon
command="/usr/bin/mongod"
command_args="--config ${MONGOD_CONFIG}"
command_user="${MONGOD_USER}:${MONGOD_GROUP}"
output_log="$MONGOD_LOGFILE"
error_log="$output_log"
depend() {
need net
after firewall
}
The script doesn't work though. When I start it with doas rc-service mongodb start --verbose
it return:
* Executing: /usr/lib/openrc/sh/openrc-run.sh /usr/lib/openrc/sh/openrc-run.sh /etc/init.d/mongodb start
* Starting mongodb ... * supervise-daemon: fopen `/run/mongodb.pid': No such file or directory
* Detaching to start `/usr/bin/mongod'
[ ok ]
But I can't find the pid file for the service, any suggestions?