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

Add cron worker with journalctl cleaner #2790

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
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: 2 additions & 0 deletions core/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ COPY services /home/pi/services
RUN /home/pi/services/install-services.sh
COPY start-blueos-core /usr/bin/start-blueos-core
COPY run-service.sh /usr/bin/run-service
RUN rm -f /etc/cron.d/*
COPY cron /etc/cron.d

# Copy binaries and necessary folders from downloadBinaries to this stage
COPY --from=downloadBinaries \
Expand Down
1 change: 1 addition & 0 deletions core/cron/waste-collector
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0 */4 * * * root journalctl-vacuum # Run every 4 hours
8 changes: 7 additions & 1 deletion core/services/install-services.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@ set -e
BUILD_PACKAGES=(
g++
)
EXTERNAL_PROGRAMS=(
cron
)

apt update

# Install build packages if not on armv7, which we have all pre-built wheels for
if ! { [ "$TARGETARCH" == "arm" ] && [ "$TARGETVARIANT" == "v7" ]; }; then
apt update
apt install -y --no-install-recommends ${BUILD_PACKAGES[*]}
fi

apt install -y --no-install-recommends ${EXTERNAL_PROGRAMS[*]}

# Wifi service:
## Bind path for wpa
mkdir -p /var/run/wpa_supplicant/
Expand Down
3 changes: 3 additions & 0 deletions core/start-blueos-core
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ mkdir -p /usr/blueos/userdata/settings
find /usr/blueos -type d -exec chmod a+rw {} \;
find /usr/blueos -type f -exec chmod a+rw {} \;

cron || echo "Failed to start cron service!"
journalctl-vacuum || echo "Failed to run journalctl-vacuum service!"

# These services have priority because they do the fundamental for the vehicle to work,
# and by initializing them first we reduce the time users have to wait to control the vehicle.
# From tests with QGC and Pi3, the reboot time was ~1min42s when not using this strategy,
Expand Down
1 change: 1 addition & 0 deletions core/tools/scripts/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ set -e

SCRIPTS_PATH="$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}"; )" &> /dev/null && pwd 2> /dev/null; )";
cp $SCRIPTS_PATH/red-pill /usr/bin/
cp $SCRIPTS_PATH/journalctl-vacuum /usr/bin/
8 changes: 8 additions & 0 deletions core/tools/scripts/journalctl-vacuum
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/local/bin/python
from commonwealth.utils.commands import run_command
from loguru import logger

if __name__ == "__main__":
ret = run_command("sudo journalctl --vacuum-size=100M", False)
logger.add("/tmp/journal-vacuum.log")
logger.debug(f"Command output: {ret}")