Skip to content

Commit c0a2b93

Browse files
authored
fix(docker): enable docker logs for pd/store/server containers (#2980)
* fix(docker): wire console appender to AsyncLogger for hugegraph server
1 parent 9126c80 commit c0a2b93

File tree

10 files changed

+42
-17
lines changed

10 files changed

+42
-17
lines changed

hugegraph-pd/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ LABEL maintainer="HugeGraph Docker Maintainers <dev@hugegraph.apache.org>"
3535

3636
# TODO: use g1gc or zgc as default
3737
ENV JAVA_OPTS="-XX:+UnlockExperimentalVMOptions -XX:+UseContainerSupport -XX:MaxRAMPercentage=50 -XshowSettings:vm" \
38-
HUGEGRAPH_HOME="hugegraph-pd"
38+
HUGEGRAPH_HOME="hugegraph-pd" \
39+
STDOUT_MODE="true"
3940

4041
#COPY . /hugegraph/hugegraph-pd
4142
WORKDIR /hugegraph-pd/

hugegraph-pd/hg-pd-dist/src/assembly/static/bin/start-hugegraph-pd.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,13 @@ echo "Starting HugeGraphPDServer..."
168168
JVM_OPTIONS="-Dlog4j.configurationFile=${CONF}/log4j2.xml -Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager"
169169

170170
# Turn on security check
171-
exec ${JAVA} -Dname="HugeGraphPD" ${JVM_OPTIONS} ${JAVA_OPTIONS} -jar \
172-
-Dspring.config.location=${CONF}/application.yml ${LIB}/hg-pd-service-*.jar >> ${OUTPUT} 2>&1 &
171+
if [[ "${STDOUT_MODE:-false}" == "true" ]]; then
172+
exec ${JAVA} -Dname="HugeGraphPD" ${JVM_OPTIONS} ${JAVA_OPTIONS} -jar \
173+
-Dspring.config.location=${CONF}/application.yml ${LIB}/hg-pd-service-*.jar &
174+
else
175+
exec ${JAVA} -Dname="HugeGraphPD" ${JVM_OPTIONS} ${JAVA_OPTIONS} -jar \
176+
-Dspring.config.location=${CONF}/application.yml ${LIB}/hg-pd-service-*.jar >> ${OUTPUT} 2>&1 &
177+
fi
173178

174179
PID="$!"
175180
# Write pid to file

hugegraph-pd/hg-pd-dist/src/assembly/static/conf/log4j2.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@
115115

116116
<loggers>
117117
<root level="INFO">
118+
<appender-ref ref="console" />
118119
<appender-ref ref="file" />
119120
</root>
120121
<logger name="com.alipay.sofa" level="INFO" additivity="false">

hugegraph-server/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ LABEL maintainer="HugeGraph Docker Maintainers <dev@hugegraph.apache.org>"
3636
# TODO: use g1gc or zgc as default
3737
# Note: --add-exports is required for Java 11+ to access jdk.internal.reflect for auth proxy
3838
ENV JAVA_OPTS="-XX:+UnlockExperimentalVMOptions -XX:+UseContainerSupport -XX:MaxRAMPercentage=50 -XshowSettings:vm --add-exports=java.base/jdk.internal.reflect=ALL-UNNAMED" \
39-
HUGEGRAPH_HOME="hugegraph-server"
39+
HUGEGRAPH_HOME="hugegraph-server" \
40+
STDOUT_MODE="true"
4041

4142
#COPY . /hugegraph/hugegraph-server
4243
WORKDIR /hugegraph-server/

hugegraph-server/hugegraph-dist/src/assembly/static/bin/hugegraph-server.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,11 @@ if [ "${OPEN_TELEMETRY}" == "true" ]; then
183183
fi
184184

185185
# Turn on security check
186-
exec ${JAVA} -Dname="HugeGraphServer" ${JVM_OPTIONS} ${JAVA_OPTIONS} -cp ${CLASSPATH}: \
187-
org.apache.hugegraph.dist.HugeGraphServer ${GREMLIN_SERVER_CONF} ${REST_SERVER_CONF} \
188-
>> ${OUTPUT} 2>&1
186+
if [[ "${STDOUT_MODE:-false}" == "true" ]]; then
187+
exec ${JAVA} -Dname="HugeGraphServer" ${JVM_OPTIONS} ${JAVA_OPTIONS} -cp ${CLASSPATH}: \
188+
org.apache.hugegraph.dist.HugeGraphServer ${GREMLIN_SERVER_CONF} ${REST_SERVER_CONF}
189+
else
190+
exec ${JAVA} -Dname="HugeGraphServer" ${JVM_OPTIONS} ${JAVA_OPTIONS} -cp ${CLASSPATH}: \
191+
org.apache.hugegraph.dist.HugeGraphServer ${GREMLIN_SERVER_CONF} ${REST_SERVER_CONF} \
192+
>> ${LOGS}/hugegraph-server-stdout.log 2>&1
193+
fi

hugegraph-server/hugegraph-dist/src/assembly/static/bin/start-hugegraph.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,17 +99,14 @@ if [[ $PRELOAD == "true" ]]; then
9999
sed -i -e '/registerBackends/d; /serverStarted/d' "${SCRIPTS}/${EXAMPLE_SCRIPT}"
100100
fi
101101

102-
# TODO: show the output message in hugegraph-server.sh when start the server
103102
if [[ $DAEMON == "true" ]]; then
104103
echo "Starting HugeGraphServer in daemon mode..."
105104
"${BIN}"/hugegraph-server.sh "${CONF}/${GREMLIN_SERVER_CONF}" "${CONF}"/rest-server.properties \
106-
"${OPEN_SECURITY_CHECK}" "${USER_OPTION}" "${GC_OPTION}" "${OPEN_TELEMETRY}" \
107-
>>"${LOGS}"/hugegraph-server.log 2>&1 &
105+
"${OPEN_SECURITY_CHECK}" "${USER_OPTION}" "${GC_OPTION}" "${OPEN_TELEMETRY}" &
108106
else
109107
echo "Starting HugeGraphServer in foreground mode..."
110108
"${BIN}"/hugegraph-server.sh "${CONF}/${GREMLIN_SERVER_CONF}" "${CONF}"/rest-server.properties \
111-
"${OPEN_SECURITY_CHECK}" "${USER_OPTION}" "${GC_OPTION}" "${OPEN_TELEMETRY}" \
112-
>>"${LOGS}"/hugegraph-server.log 2>&1
109+
"${OPEN_SECURITY_CHECK}" "${USER_OPTION}" "${GC_OPTION}" "${OPEN_TELEMETRY}"
113110
fi
114111

115112
PID="$!"
@@ -119,7 +116,11 @@ echo "$PID" > "$PID_FILE"
119116
trap 'kill $PID; exit' SIGHUP SIGINT SIGQUIT SIGTERM
120117

121118
wait_for_startup ${PID} 'HugeGraphServer' "$REST_SERVER_URL/graphs" "${SERVER_STARTUP_TIMEOUT_S}" || {
122-
echo "See $LOGS/hugegraph-server.log for HugeGraphServer log output." >&2
119+
if [[ "${STDOUT_MODE:-false}" == "true" ]]; then
120+
echo "See 'docker logs' for HugeGraphServer log output." >&2
121+
else
122+
echo "See $LOGS/hugegraph-server.log for HugeGraphServer log output." >&2
123+
fi
123124
if [[ $DAEMON == "true" ]]; then
124125
exit 1
125126
fi

hugegraph-server/hugegraph-dist/src/assembly/static/conf/log4j2.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104

105105
<loggers>
106106
<root level="INFO">
107+
<appender-ref ref="console"/>
107108
<appender-ref ref="file"/>
108109
</root>
109110
<logger name="org.apache.cassandra" level="INFO" additivity="false">
@@ -129,6 +130,7 @@
129130
</logger>
130131
<!-- Use mixed async way to output logs -->
131132
<AsyncLogger name="org.apache.hugegraph" level="INFO" additivity="false">
133+
<appender-ref ref="console"/>
132134
<appender-ref ref="file"/>
133135
</AsyncLogger>
134136
<AsyncLogger name="org.apache.hugegraph.auth" level="INFO" additivity="false">

hugegraph-store/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ LABEL maintainer="HugeGraph Docker Maintainers <dev@hugegraph.apache.org>"
3535

3636
# TODO: use g1gc or zgc as default
3737
ENV JAVA_OPTS="-XX:+UnlockExperimentalVMOptions -XX:+UseContainerSupport -XX:MaxRAMPercentage=50 -XshowSettings:vm" \
38-
HUGEGRAPH_HOME="hugegraph-store"
38+
HUGEGRAPH_HOME="hugegraph-store" \
39+
STDOUT_MODE="true"
3940

4041
#COPY . /hugegraph/hugegraph-store
4142
WORKDIR /hugegraph-store/

hugegraph-store/hg-store-dist/src/assembly/static/bin/start-hugegraph-store.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,16 @@ fi
221221

222222
echo "Starting HG-StoreServer..."
223223

224-
exec ${JAVA} -Dname="HugeGraphStore" ${JVM_OPTIONS} ${JAVA_OPTIONS} -jar \
225-
-Dspring.config.location=${CONF}/application.yml \
226-
${LIB}/hg-store-node-*.jar >> ${OUTPUT} 2>&1 &
224+
# Turn on security check
225+
if [[ "${STDOUT_MODE:-false}" == "true" ]]; then
226+
exec ${JAVA} -Dname="HugeGraphStore" ${JVM_OPTIONS} ${JAVA_OPTIONS} -jar \
227+
-Dspring.config.location=${CONF}/application.yml \
228+
${LIB}/hg-store-node-*.jar &
229+
else
230+
exec ${JAVA} -Dname="HugeGraphStore" ${JVM_OPTIONS} ${JAVA_OPTIONS} -jar \
231+
-Dspring.config.location=${CONF}/application.yml \
232+
${LIB}/hg-store-node-*.jar >> ${OUTPUT} 2>&1 &
233+
fi
227234

228235
PID="$!"
229236
# Write pid to file

hugegraph-store/hg-store-dist/src/assembly/static/conf/log4j2.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117

118118
<loggers>
119119
<root level="INFO">
120+
<appender-ref ref="console"/>
120121
<appender-ref ref="file"/>
121122
</root>
122123
<logger name="com.alipay.sofa" level="INFO" additivity="false">

0 commit comments

Comments
 (0)