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