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

Try to recover the system if available size in critical #2325

Merged
merged 2 commits into from
Jan 22, 2024
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
2 changes: 1 addition & 1 deletion core/services/commander/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from loguru import logger

SERVICE_NAME = "commander"
LOG_FOLDER_PATH = "/var/logs/blueos"
LOG_FOLDER_PATH = os.environ.get("BLUEOS_LOG_FOLDER_PATH", "/var/logs/blueos")

limit_ram_usage()

Expand Down
18 changes: 17 additions & 1 deletion core/start-blueos-core
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,22 @@ MAV_COMPONENT_ID_ONBOARD_COMPUTER4=194
# Enable Rust backtrace for all programs
RUST_BACKTRACE=1

# Set BlueOS log folder
BLUEOS_LOG_FOLDER_PATH="/var/logs/blueos"

# The system may start with full disk, in this case resulting in an unstable behavior.
# As an attempt to recover the system, lets delete the log files before current boot
AVAILABLE_SPACE_MB=$(($(stat -f / --format="%a*%S/1024**2")))
CRITICAL_SPACE_LIMIT_MB=100
echo "Available disk space: ${AVAILABLE_SPACE_MB}MB"
(( AVAILABLE_SPACE_MB < CRITICAL_SPACE_LIMIT_MB )) && (
LOG_FOLDER_SIZE=$(($(du -sm ${BLUEOS_LOG_FOLDER_PATH} | awk '{print $1}')))
echo "Not enough free space for the system to run, limit is: ${CRITICAL_SPACE_LIMIT_MB}MB"
echo "Going to delete the logs folder as an attempt to recover: ${LOG_FOLDER_SIZE}MB"
rm -rf "$BLUEOS_LOG_FOLDER_PATH/*"
echo "Done!"
)

# Update docker binds, if we need to restart, exit!
blueos_startup_update

Expand Down Expand Up @@ -112,7 +128,7 @@ function create_service {
fi

# Set all necessary environment variables for the new tmux session
for NAME in $(compgen -v | grep MAV_); do
for NAME in $(compgen -v | grep -e MAV_ -e BLUEOS_); do
VALUE=${!NAME}
tmux setenv -t $SESSION_NAME -g $NAME $VALUE
done
Expand Down
Loading