Skip to content

Commit 7bb809d

Browse files
authored
Server log (#173)
* chore: update log * chore: update log * chore: redirect log
1 parent 95a596e commit 7bb809d

File tree

4 files changed

+34
-12
lines changed

4 files changed

+34
-12
lines changed

deploy/server.ts

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,33 @@ const setOrUpdateMetaTag = ($: CheerioAPI, selector: string, attribute: string,
2020
}
2121
};
2222

23-
const logger = pino({
24-
transport: {
25-
target: 'pino-pretty',
26-
options: {
27-
colorize: true,
28-
translateTime: 'SYS:standard',
29-
},
23+
const prettyTransport = {
24+
target: 'pino-pretty',
25+
options: {
26+
colorize: true,
27+
translateTime: 'SYS:standard',
3028
},
29+
};
30+
31+
const logger = pino({
32+
transport: process.env.NODE_ENV === 'production' ? undefined : prettyTransport,
3133
level: process.env.LOG_LEVEL || 'info',
3234
});
3335

3436
const logRequestTimer = (req: Request) => {
3537
const start = Date.now();
3638
const pathname = new URL(req.url).pathname;
3739

38-
logger.info(`Incoming request: ${pathname}`);
40+
if (!pathname.startsWith('/health')) {
41+
logger.info(`Incoming request: ${pathname}`);
42+
}
43+
3944
return () => {
4045
const duration = Date.now() - start;
4146

42-
logger.info(`Request for ${pathname} took ${duration}ms`);
47+
if (!pathname.startsWith('/health')) {
48+
logger.info(`Request for ${pathname} took ${duration}ms`);
49+
}
4350
};
4451
};
4552

@@ -76,7 +83,9 @@ const createServer = async (req: Request) => {
7683
const reqUrl = new URL(req.url);
7784
const hostname = req.headers.get('host');
7885

79-
logger.info(`Request URL: ${hostname}${reqUrl.pathname}`);
86+
if (!reqUrl.pathname.startsWith('/health')) {
87+
logger.info(`Request URL: ${hostname}${reqUrl.pathname}`);
88+
}
8089

8190
if (reqUrl.pathname === '/') {
8291
timer();

docker/Dockerfile.ssr

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Build stage - Build the React application
33
FROM node:20.12.0-alpine AS builder
44

5+
ARG VERSION=dev
56
ENV NODE_ENV=production
67

78
WORKDIR /app
@@ -46,6 +47,10 @@ COPY docker/entrypoint-ssr.sh /docker-entrypoint.sh
4647
# Make entrypoint executable
4748
RUN chmod +x /docker-entrypoint.sh
4849

50+
# Set version as environment variable (from build arg)
51+
ARG VERSION
52+
ENV APP_VERSION=${VERSION}
53+
4954
# Expose port 80
5055
EXPOSE 80
5156

docker/entrypoint-ssr.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#!/bin/sh
22
set -e
33

4+
# Print version banner
5+
echo "════════════════════════════════════════════════════════════════════"
6+
echo " AppFlowy Web v${APP_VERSION:-dev}"
7+
echo "════════════════════════════════════════════════════════════════════"
8+
echo ""
9+
410
# Backward compatibility: Map old environment variable names to new ones
511
if [ -n "${AF_BASE_URL}" ] && [ -z "${APPFLOWY_BASE_URL}" ]; then
612
echo "⚠️ WARNING: AF_BASE_URL is deprecated. Please use APPFLOWY_BASE_URL instead."

docker/supervisord-ssr.conf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ priority=10
1919
command=bun run /app/server.ts
2020
autostart=true
2121
autorestart=true
22-
stdout_logfile=/var/log/bun.out.log
23-
stderr_logfile=/var/log/bun.err.log
22+
stdout_logfile=/dev/stdout
23+
stdout_logfile_maxbytes=0
24+
stderr_logfile=/dev/stderr
25+
stderr_logfile_maxbytes=0
2426
environment=NODE_ENV="production"
2527
priority=20

0 commit comments

Comments
 (0)