This document describes how to deploy the TsFile Viewer application in different modes.
In embedded mode, the frontend static assets are bundled within the Spring Boot JAR, resulting in a single deployable artifact.
Linux/Mac:
chmod +x build-embedded.sh ./build-embedded.sh
Windows:
build-embedded.bat
java -jar backend/target/tsfile-viewer-*.jar
The application will be available at: http://localhost:8080/view/
Edit backend/src/main/resources/application.yml:
server: port: 8080 tsfile: allowed-directories: - /data/tsfiles - /uploads/tsfiles upload-directory: /uploads/tsfiles
In separate mode, the frontend and backend are deployed independently, allowing for CDN hosting of static assets and horizontal scaling.
Linux/Mac:
chmod +x build-separate.sh ./build-separate.sh
Windows:
build-separate.bat
Copy frontend/dist/ to your web server directory:
cp -r frontend/dist/* /var/www/tsfile-viewer/
Configure Nginx:
server { listen 80; server_name tsfile-viewer.example.com; root /var/www/tsfile-viewer; index index.html; # SPA routing fallback location / { try_files $uri $uri/ /index.html; } # Proxy API requests to backend location /api { proxy_pass http://backend-server:8080; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } # Cache static assets location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { expires 1y; add_header Cache-Control "public, immutable"; } }
Upload frontend/dist/ to your CDN (S3, CloudFront, etc.)
Set environment variable for API base URL:
export VITE_API_BASE_URL=https://api.example.com/api
Rebuild frontend with the environment variable:
cd frontend
pnpm build
Run the Spring Boot JAR:
java -jar backend/target/tsfile-viewer-*.jar
Configure Nginx or another reverse proxy to route /api requests to the backend. This is the recommended way to connect the frontend and backend in separate deployment.
For production, use systemd service:
Create /etc/systemd/system/tsfile-viewer.service:
[Unit] Description=TsFile Viewer Backend After=network.target [Service] Type=simple User=tsfile WorkingDirectory=/opt/tsfile-viewer ExecStart=/usr/bin/java -jar /opt/tsfile-viewer/tsfile-viewer.jar Restart=on-failure RestartSec=10 [Install] WantedBy=multi-user.target
Enable and start:
sudo systemctl enable tsfile-viewer sudo systemctl start tsfile-viewer
Edit backend/src/main/resources/application.yml:
server: port: 8080 servlet: context-path: / spring: servlet: multipart: enabled: true max-file-size: 100MB max-request-size: 100MB file-size-threshold: 2MB tsfile: # Whitelist of allowed directories for file browsing allowed-directories: - /data/tsfiles - /uploads/tsfiles # Directory for uploaded files upload-directory: /uploads/tsfiles # Cache configuration cache: metadata: max-size: 1000 ttl-minutes: 60 reader: max-size: 100 ttl-minutes: 30 # Query configuration query: timeout-seconds: 30 max-result-size: 10000 default-page-size: 100 logging: level: org.apache.tsfile.viewer: INFO org.apache.tsfile: WARN
Create .env.production in frontend/:
# API base URL (for separate deployment) VITE_API_BASE_URL=https://api.example.com/api # For embedded deployment, leave empty or use relative path # VITE_API_BASE_URL=/api
tsfile.allowed-directories to restrict file system accessspring.servlet.multipart.max-file-size based on your needsJVM Options: Tune JVM heap size based on file sizes and concurrent users
java -Xms2g -Xmx4g -jar tsfile-viewer.jar
Cache Configuration: Adjust cache sizes based on available memory
tsfile: cache: metadata: max-size: 2000 # Increase for more files reader: max-size: 200 # Increase for more concurrent users
Frontend CDN: Use CDN for static assets to reduce server load
Database: For view persistence, configure a production database instead of in-memory storage
Spring Boot Actuator: Enable health checks and metrics
management: endpoints: web: exposure: include: health,info,metrics
Logging: Configure log rotation and retention
logging: file: name: /var/log/tsfile-viewer/application.log max-size: 10MB max-history: 30
upload-directoryapplication.yml and environment variablesVITE_API_BASE_URL - it should match your proxy entry point (default: /api)spring.servlet.multipart.max-file-size settingupload-directory exists and has write permissionsTSFILE_ALLOWED_DIRS: Comma-separated allowed directory list (e.g. /data/tsfiles,/uploads/tsfiles)TSFILE_UPLOAD_DIR: Upload directory path (must be within allowed directories)-Xmx flagquery.max-result-size to limit result setsquery.timeout-seconds for large filesFor issues and questions, please refer to:
/swagger-ui.html (if enabled)