diff --git a/nightscout/rootfs/etc/services.d/mongodb/finish b/nightscout/rootfs/etc/services.d/mongodb/finish new file mode 100755 index 0000000..68c6ffc --- /dev/null +++ b/nightscout/rootfs/etc/services.d/mongodb/finish @@ -0,0 +1,10 @@ +#!/usr/bin/with-contenv bash +# ============================================================================== +# Gracefully stop MongoDB +# ============================================================================== + +# Send the SIGTERM signal to MongoDB to allow it to perform a graceful shutdown +pkill -SIGTERM mongod + +# Wait for MongoDB to shut down +timeout 30 sh -c 'until [ "$(pgrep mongod)" = "" ]; do sleep 1; done' diff --git a/nightscout/rootfs/etc/services.d/mongodb/run b/nightscout/rootfs/etc/services.d/mongodb/run new file mode 100755 index 0000000..90ca0b6 --- /dev/null +++ b/nightscout/rootfs/etc/services.d/mongodb/run @@ -0,0 +1,14 @@ +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Home Assistant Add-on: Nightscout +# Runs MongoDB +# ============================================================================== + +bashio::log.info "Starting MongoDB..." + +# Set the data directory and bind IP address +export MONGODB_DBPATH="/var/lib/mongodb" +export MONGODB_BIND_IP="127.0.0.1" + +# Start MongoDB with the specified options +exec s6-setuidgid mongodb /usr/bin/mongod --dbpath "$MONGODB_DBPATH" --bind_ip "$MONGODB_BIND_IP" diff --git a/nightscout/rootfs/etc/services.d/nightscout/run b/nightscout/rootfs/etc/services.d/nightscout/run index dac8b0d..a8359a8 100755 --- a/nightscout/rootfs/etc/services.d/nightscout/run +++ b/nightscout/rootfs/etc/services.d/nightscout/run @@ -7,7 +7,6 @@ declare -a options # Wait for MongoDB to become available -service mongodb start bashio::net.wait_for 27017 bashio::log.info 'Starting the Nightscout server...'