-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path00-start-server-common.sh
More file actions
executable file
·62 lines (53 loc) · 1.82 KB
/
00-start-server-common.sh
File metadata and controls
executable file
·62 lines (53 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
# Common server startup functions
# Source this script from other server startup scripts
# Navigate to project root
cd "$(dirname "$0")"
export MAVEN_OPTS="-Djava.net.preferIPv4Stack=true"
# Function to build the project
build_project() {
echo "Building PrefHub..."
mvn install -N
mvn clean package -DskipTests -pl prefhub-core,prefhub-server -am
if [ $? -ne 0 ]; then
echo "Build failed!"
exit 1
fi
}
# Function to set up classpath
setup_classpath() {
# Set up classpath with all dependencies
CORE_JAR="prefhub-core/target/prefhub-core-1.0-SNAPSHOT.jar"
SERVER_JAR="prefhub-server/target/prefhub-server-1.0-SNAPSHOT.jar"
DEPS_DIR="prefhub-server/target/dependency"
# Download dependencies if needed
if [ ! -d "$DEPS_DIR" ]; then
echo "Downloading dependencies..."
mvn dependency:copy-dependencies -DoutputDirectory=target/dependency -pl prefhub-server
fi
# Build classpath (server JAR + core JAR + all dependencies)
# Use the actual core JAR from target, not from dependencies (which may be outdated)
CLASSPATH="$SERVER_JAR:$CORE_JAR"
for jar in "$DEPS_DIR"/*.jar; do
# Skip prefhub-core if it's in dependencies (we use the fresh one from target)
if [[ "$jar" != *"prefhub-core"* ]]; then
CLASSPATH="$CLASSPATH:$jar"
fi
done
# Export for use in calling script
export CLASSPATH
}
# Function to copy rules files
copy_rules() {
echo "Copying rules files..."
mkdir -p ./game-data/rules
cp -f prefhub-server/src/main/resources/rules/*.json ./game-data/rules/
}
# Function to start server with given arguments
start_server() {
echo "Starting PrefHub server..."
java -Djava.net.preferIPv4Stack=true \
-cp "$CLASSPATH" \
com.prefhub.server.ServerMain \
"$@"
}