Stop services if drive space is extremely low
This commit is contained in:
parent
6939d65a22
commit
b20c67ee35
|
@ -15,6 +15,16 @@ echo "Found Drive: $drive"
|
|||
lsblk $drive &> /dev/null
|
||||
while [ $? -eq 0 ]; do
|
||||
#echo "$drive still found..."
|
||||
|
||||
# Check drive usage
|
||||
usage=$(df -h /mnt/hdd | grep /dev | awk '{print $5}' | cut -d'%' -f1)
|
||||
echo "Usage $usage"
|
||||
if [ $usage -ge 99 ]; then
|
||||
# Usage is 99%+, reboot to get into drive_full state with services stopped
|
||||
/usr/bin/mynode-reboot
|
||||
fi
|
||||
|
||||
# Wait, check again in one minute
|
||||
sleep 60
|
||||
lsblk $drive &> /dev/null
|
||||
done
|
||||
|
|
|
@ -116,6 +116,15 @@ if [ -f /home/bitcoin/reset_docker ]; then
|
|||
fi
|
||||
|
||||
|
||||
# Check drive usage
|
||||
usage=$(df -h /mnt/hdd | grep /dev | awk '{print $5}' | cut -d'%' -f1)
|
||||
while [ $usage -ge 98 ]; do
|
||||
echo "drive_full" > $MYNODE_STATUS_FILE
|
||||
sleep 10s
|
||||
usage=$(df -h /mnt/hdd | grep /dev | awk '{print $5}' | cut -d'%' -f1)
|
||||
done
|
||||
|
||||
|
||||
# Setup Drive
|
||||
mkdir -p /mnt/hdd/mynode
|
||||
mkdir -p /mnt/hdd/mynode/settings
|
||||
|
|
|
@ -389,6 +389,7 @@ STATE_DRIVE_MISSING = "drive_missing"
|
|||
STATE_DRIVE_CONFIRM_FORMAT = "drive_format_confirm"
|
||||
STATE_DRIVE_FORMATTING = "drive_formatting"
|
||||
STATE_DRIVE_MOUNTED = "drive_mounted"
|
||||
STATE_DRIVE_FULL = "drive_full"
|
||||
STATE_GEN_DHPARAM = "gen_dhparam"
|
||||
STATE_QUICKSYNC_DOWNLOAD = "quicksync_download"
|
||||
STATE_QUICKSYNC_COPY = "quicksync_copy"
|
||||
|
|
|
@ -212,6 +212,20 @@ def index():
|
|||
"ui_settings": read_ui_settings()
|
||||
}
|
||||
return render_template('state.html', **templateData)
|
||||
elif status == STATE_DRIVE_FULL:
|
||||
message = "Your drive is full!<br/><br/>"
|
||||
message += "<p style='font-size: 16px; width: 800px; margin: auto;'>"
|
||||
message += "To prevent corrupting any data, your device has stopped running most apps until more free space is available. "
|
||||
message += "Please free up some space or attach a larger drive.<br/><br/>"
|
||||
message += "If enabled, disabling QuickSync can save a large amount of space."
|
||||
message += "</p>"
|
||||
templateData = {
|
||||
"title": "myNode Drive Full",
|
||||
"header_text": "Drive Full",
|
||||
"subheader_text": Markup(message),
|
||||
"ui_settings": read_ui_settings()
|
||||
}
|
||||
return render_template('state.html', **templateData)
|
||||
elif status == STATE_GEN_DHPARAM:
|
||||
templateData = {
|
||||
"title": "myNode Generating Data",
|
||||
|
|
Loading…
Reference in New Issue
Block a user