mirror of
https://github.com/AppFlowy-IO/AppFlowy-Web.git
synced 2025-11-29 02:38:00 +08:00
Server log (#173)
* chore: update log * chore: update log * chore: redirect log
This commit is contained in:
@@ -20,14 +20,16 @@ const setOrUpdateMetaTag = ($: CheerioAPI, selector: string, attribute: string,
|
||||
}
|
||||
};
|
||||
|
||||
const logger = pino({
|
||||
transport: {
|
||||
const prettyTransport = {
|
||||
target: 'pino-pretty',
|
||||
options: {
|
||||
colorize: true,
|
||||
translateTime: 'SYS:standard',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const logger = pino({
|
||||
transport: process.env.NODE_ENV === 'production' ? undefined : prettyTransport,
|
||||
level: process.env.LOG_LEVEL || 'info',
|
||||
});
|
||||
|
||||
@@ -35,11 +37,16 @@ const logRequestTimer = (req: Request) => {
|
||||
const start = Date.now();
|
||||
const pathname = new URL(req.url).pathname;
|
||||
|
||||
if (!pathname.startsWith('/health')) {
|
||||
logger.info(`Incoming request: ${pathname}`);
|
||||
}
|
||||
|
||||
return () => {
|
||||
const duration = Date.now() - start;
|
||||
|
||||
if (!pathname.startsWith('/health')) {
|
||||
logger.info(`Request for ${pathname} took ${duration}ms`);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -76,7 +83,9 @@ const createServer = async (req: Request) => {
|
||||
const reqUrl = new URL(req.url);
|
||||
const hostname = req.headers.get('host');
|
||||
|
||||
if (!reqUrl.pathname.startsWith('/health')) {
|
||||
logger.info(`Request URL: ${hostname}${reqUrl.pathname}`);
|
||||
}
|
||||
|
||||
if (reqUrl.pathname === '/') {
|
||||
timer();
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
# Build stage - Build the React application
|
||||
FROM node:20.12.0-alpine AS builder
|
||||
|
||||
ARG VERSION=dev
|
||||
ENV NODE_ENV=production
|
||||
|
||||
WORKDIR /app
|
||||
@@ -46,6 +47,10 @@ COPY docker/entrypoint-ssr.sh /docker-entrypoint.sh
|
||||
# Make entrypoint executable
|
||||
RUN chmod +x /docker-entrypoint.sh
|
||||
|
||||
# Set version as environment variable (from build arg)
|
||||
ARG VERSION
|
||||
ENV APP_VERSION=${VERSION}
|
||||
|
||||
# Expose port 80
|
||||
EXPOSE 80
|
||||
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
# Print version banner
|
||||
echo "════════════════════════════════════════════════════════════════════"
|
||||
echo " AppFlowy Web v${APP_VERSION:-dev}"
|
||||
echo "════════════════════════════════════════════════════════════════════"
|
||||
echo ""
|
||||
|
||||
# Backward compatibility: Map old environment variable names to new ones
|
||||
if [ -n "${AF_BASE_URL}" ] && [ -z "${APPFLOWY_BASE_URL}" ]; then
|
||||
echo "⚠️ WARNING: AF_BASE_URL is deprecated. Please use APPFLOWY_BASE_URL instead."
|
||||
|
||||
@@ -19,7 +19,9 @@ priority=10
|
||||
command=bun run /app/server.ts
|
||||
autostart=true
|
||||
autorestart=true
|
||||
stdout_logfile=/var/log/bun.out.log
|
||||
stderr_logfile=/var/log/bun.err.log
|
||||
stdout_logfile=/dev/stdout
|
||||
stdout_logfile_maxbytes=0
|
||||
stderr_logfile=/dev/stderr
|
||||
stderr_logfile_maxbytes=0
|
||||
environment=NODE_ENV="production"
|
||||
priority=20
|
||||
Reference in New Issue
Block a user