Skip to content

Commit

Permalink
Merge pull request #17 from marciogranzotto/marcio/fix-mongodb
Browse files Browse the repository at this point in the history
Fix MongoDB failing to init
  • Loading branch information
marciogranzotto authored Apr 20, 2023
2 parents c38918c + 430b6d1 commit e33a195
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
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

0 comments on commit e33a195

Please sign in to comment.