-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstart-sonarqube-railway.sh
More file actions
executable file
·59 lines (49 loc) · 1.91 KB
/
Copy pathstart-sonarqube-railway.sh
File metadata and controls
executable file
·59 lines (49 loc) · 1.91 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
#!/bin/bash
set -e
echo "=== SonarQube Ultimate Railway Configuration ==="
echo "Port: ${PORT:-9000}"
echo "Database: ${SONAR_JDBC_URL}"
# Ensure we have the correct port
export SONAR_WEB_PORT=${PORT:-9000}
# Force Elasticsearch memory settings in environment
export ES_JAVA_OPTS="-Xms256m -Xmx512m -XX:MaxDirectMemorySize=256m"
export SONAR_SEARCH_JAVA_OPTS="-Xms256m -Xmx512m -XX:MaxDirectMemorySize=256m"
export SONAR_SEARCH_JAVA_ADDITIONAL_OPTS="-Des.enforce.bootstrap.checks=false -Des.node.store.allow_mmap=false"
# Create a wrapper for the java command to intercept ES startup
cat > /usr/local/bin/java-wrapper << 'EOF'
#!/bin/bash
# Check if this is an Elasticsearch process
if echo "$@" | grep -q "elasticsearch"; then
echo "[Java Wrapper] Detected Elasticsearch startup"
# Filter out the low memory settings and inject our own
NEW_ARGS=""
skip_next=false
for arg in "$@"; do
if [[ "$arg" =~ ^-Xms4m$ ]] || [[ "$arg" =~ ^-Xmx64m$ ]]; then
continue
fi
NEW_ARGS="$NEW_ARGS $arg"
done
echo "[Java Wrapper] Starting ES with: java -Xms256m -Xmx512m $NEW_ARGS"
exec /opt/java/openjdk/bin/java -Xms256m -Xmx512m $NEW_ARGS
else
# Not ES, run normally
exec /opt/java/openjdk/bin/java "$@"
fi
EOF
chmod +x /usr/local/bin/java-wrapper
# Temporarily replace java in PATH
export PATH="/usr/local/bin:$PATH"
# Update sonar.properties with our settings
cat >> /opt/sonarqube/conf/sonar.properties << EOF
# Railway-specific settings
sonar.web.port=${PORT:-9000}
sonar.search.javaOpts=-Xms256m -Xmx512m -XX:MaxDirectMemorySize=256m
sonar.search.javaAdditionalOpts=-Des.enforce.bootstrap.checks=false -Des.node.store.allow_mmap=false
sonar.web.javaOpts=-Xmx384m -Xms128m
sonar.ce.javaOpts=-Xmx384m -Xms128m
EOF
echo "Starting SonarQube with forced memory configuration..."
# Start SonarQube
exec java -jar /opt/sonarqube/lib/sonar-application-*.jar \
-Dsonar.log.console=true