Skip to content

1️⃣ Direct Deployment

⚠️ Important Note: The current project directory is missing backend and frontend source code, direct deployment is temporarily unavailable. The following documentation is a theoretical deployment guide that will be available once the project code is complete.

Direct deployment is suitable for development environments or scenarios requiring deep customization, involving manual configuration and startup of each component.

Prerequisites

  • Java 21: OpenJDK 21 or Temurin 21
  • Node.js 18+: For frontend building
  • MySQL 8.0+: Database service
  • Maven: Project includes Maven Wrapper, no separate installation needed

Deployment Steps

1. Environment Preparation

bash
# Check Java version
java -version

# Check Node.js version
node --version

# Check MySQL version
mysql --version

2. Database Initialization

bash
# Log in to MySQL
mysql -u root -p

# Create database and user
CREATE DATABASE IF NOT EXISTS astrnest CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER IF NOT EXISTS 'astrnest'@'localhost' IDENTIFIED BY 'astrnestPass!';
GRANT ALL PRIVILEGES ON astrnest.* TO 'astrnest'@'localhost';
FLUSH PRIVILEGES;

# Or use the project's initialization script
mysql -u root -p < backend/db/init.sql

3. Environment Variables Configuration

Create .env file (based on .env.example):

bash
# Database Configuration
MYSQL_ROOT_PASSWORD=your_root_password
MYSQL_DATABASE=astrnest
MYSQL_USER=astrnest
MYSQL_PASSWORD=astrnestPass!

# Backend Configuration
ASTRNEST_DB_URL=jdbc:mysql://localhost:3306/astrnest?useSSL=false&allowPublicKeyRetrieval=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
ASTRNEST_DB_USERNAME=astrnest
ASTRNEST_DB_PASSWORD=astrnestPass!
ASTRNEST_STORAGE_ROOT=/storage/upload
ASTRNEST_STORAGE_PUBLIC=/upload
ASTRNEST_ADMIN_USERNAME=admin
ASTRNEST_ADMIN_PASSWORD=chenxi123
ASTRNEST_ADMIN_DISPLAY=Super Administrator
ASTRNEST_ADMIN_EMAIL=admin@example.com

# Frontend Configuration
VITE_API_BASE_URL=http://localhost:8080
VITE_PUBLIC_ASSET_BASE=http://localhost:8080/upload
VITE_SITE_NAME=AstrNest

4. Start Backend Service

bash
# Enter backend directory
cd backend

# Start with Maven Wrapper (recommended)
./mvnw spring-boot:run

# Or build and run
./mvnw clean package
java -jar target/backend-0.0.1-SNAPSHOT.jar

Backend service will start at http://localhost:8080.

5. Start Frontend Service

bash
# New terminal, enter frontend directory
cd frontend

# Install dependencies
npm install

# Start in development mode
npm run dev

# Or build and preview
npm run build
npm run preview

Frontend service will start at http://localhost:5173.

Deployment Verification

Access the following addresses to verify service status:

Default Administrator Account

  • Username: admin
  • Password: chenxi123

Service Management

Using PM2 for Process Management

bash
# Install PM2
npm install -g pm2

# Start backend service
cd backend
pm2 start "java -jar target/backend-0.0.1-SNAPSHOT.jar" --name "astrnest-backend"

# Start frontend service (built static files)
cd frontend
npm run build
pm2 serve dist 5173 --name "astrnest-frontend"

# Check service status
pm2 status

Using systemd for Service Management

Create backend service file /etc/systemd/system/astrnest-backend.service:

ini
[Unit]
Description=AstrNest Backend Service
After=network.target

[Service]
Type=simple
User=astrnest
WorkingDirectory=/opt/astrnest/backend
ExecStart=/usr/bin/java -jar target/backend-0.0.1-SNAPSHOT.jar
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target

Common Issues

Port Conflicts

If ports are occupied, modify configuration:

bash
# Backend port modification
java -jar target/backend-0.0.1-SNAPSHOT.jar --server.port=8081

# Frontend port modification (development mode)
VITE_API_BASE_URL=http://localhost:8081 npm run dev -- --port=3000

Database Connection Failure

Check MySQL service status and connection configuration:

bash
# Check MySQL service status
sudo systemctl status mysql

# Check firewall settings
sudo ufw status

Insufficient Memory

Increase JVM memory configuration:

bash
java -Xmx2g -Xms1g -jar target/backend-0.0.1-SNAPSHOT.jar

Advantages and Limitations

Advantages

  • Complete control over each component
  • Easy for debugging and development
  • Flexible configuration and customization

Limitations

  • Higher deployment complexity
  • Manual service management required
  • Not suitable for large-scale production environments

Choosing direct deployment gives you full control over every component of AstrNest, suitable for deep customization and development debugging.