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

Fix MongoDB failing to init #17

Merged
merged 2 commits into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions nightscout/rootfs/etc/services.d/mongodb/finish
Original file line number Diff line number Diff line change
@@ -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'
14 changes: 14 additions & 0 deletions nightscout/rootfs/etc/services.d/mongodb/run
Original file line number Diff line number Diff line change
@@ -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"
1 change: 0 additions & 1 deletion nightscout/rootfs/etc/services.d/nightscout/run
Original file line number Diff line number Diff line change
Expand Up @@ -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...'
Expand Down