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

No useful logs going to stdout/stderr #333

Open
shaunco opened this issue Dec 1, 2023 · 1 comment
Open

No useful logs going to stdout/stderr #333

shaunco opened this issue Dec 1, 2023 · 1 comment

Comments

@shaunco
Copy link

shaunco commented Dec 1, 2023

As previously reported in balena-io/open-balena#99 the only log that gets spit out to stdout/stderr is

Systemd init system enabled.

This is the case in Kubernetes and Docker for all the open-balena-* services... which makes capturing logs quite difficult in production, especially when the container is constantly restarting.

@aslansutu
Copy link

The VPN, API, Registry, and S3 containers all seem to have the same entrypoint /usr/bin/entry.sh. The script could benefit from a more detailed logs in case of errors. Maybe something like the following;

#!/bin/bash
set -m

GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m' # No Color

# Function to print error message
print_error() {
    echo -e "${RED}Error: $1${NC}"
}

# Function to handle cleanup
cleanup() {
    # Add cleanup tasks here
    exit 1
}

# Trap error signals and call cleanup function
trap 'print_error "Script encountered an error"; cleanup' ERR

echo -e "${GREEN}Systemd init system enabled."

# systemd causes a POLLHUP for console FD to occur
# on startup once all other processes have stopped.
# We need this sleep to ensure this doesn't occur, else
# logging to the console will not work.
sleep infinity &

# Example command that may fail
# Uncomment to test error handling
#non_existent_command

for var in $(compgen -e); do
    printf '%q=%q\n' "$var" "${!var}"
done > /etc/docker.env

exec /sbin/init

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants