add source code and readme
This commit is contained in:
73
build/piefed/piefed-web/entrypoint-web.sh
Normal file
73
build/piefed/piefed-web/entrypoint-web.sh
Normal file
@@ -0,0 +1,73 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
# Source common functions
|
||||
. /usr/local/bin/entrypoint-common.sh
|
||||
|
||||
log "Starting PieFed web container..."
|
||||
|
||||
# Run common startup sequence
|
||||
common_startup
|
||||
|
||||
# Web-specific initialization
|
||||
log "Initializing web container..."
|
||||
|
||||
# Apply dual logging configuration (file + stdout for OpenObserve)
|
||||
log "Configuring dual logging for OpenObserve..."
|
||||
|
||||
# Pre-create log file with correct ownership to prevent permission issues
|
||||
log "Pre-creating log file with proper ownership..."
|
||||
touch /app/logs/pyfedi.log
|
||||
chown piefed:piefed /app/logs/pyfedi.log
|
||||
chmod 664 /app/logs/pyfedi.log
|
||||
|
||||
# Setup dual logging (file + stdout) directly
|
||||
python -c "
|
||||
import logging
|
||||
import sys
|
||||
|
||||
def setup_dual_logging():
|
||||
'''Add stdout handlers to existing loggers without disrupting file logging'''
|
||||
# Create a shared console handler
|
||||
console_handler = logging.StreamHandler(sys.stdout)
|
||||
console_handler.setLevel(logging.INFO)
|
||||
console_handler.setFormatter(logging.Formatter(
|
||||
'%(asctime)s [%(name)s] %(levelname)s: %(message)s'
|
||||
))
|
||||
|
||||
# Add console handler to key loggers (in addition to their existing file handlers)
|
||||
loggers_to_enhance = [
|
||||
'flask.app', # Flask application logger
|
||||
'werkzeug', # Web server logger
|
||||
'celery', # Celery worker logger
|
||||
'celery.task', # Celery task logger
|
||||
'celery.worker', # Celery worker logger
|
||||
'' # Root logger
|
||||
]
|
||||
|
||||
for logger_name in loggers_to_enhance:
|
||||
logger = logging.getLogger(logger_name)
|
||||
logger.setLevel(logging.INFO)
|
||||
|
||||
# Check if this logger already has a stdout handler
|
||||
has_stdout_handler = any(
|
||||
isinstance(h, logging.StreamHandler) and h.stream == sys.stdout
|
||||
for h in logger.handlers
|
||||
)
|
||||
|
||||
if not has_stdout_handler:
|
||||
logger.addHandler(console_handler)
|
||||
|
||||
print('Dual logging configured: file + stdout for OpenObserve')
|
||||
|
||||
# Call the function
|
||||
setup_dual_logging()
|
||||
"
|
||||
|
||||
# Test nginx configuration
|
||||
log "Testing nginx configuration..."
|
||||
nginx -t
|
||||
|
||||
# Start services via supervisor
|
||||
log "Starting web services (nginx + uwsgi)..."
|
||||
exec "$@"
|
||||
Reference in New Issue
Block a user