Skip to content

Commit 1c50cef

Browse files
imbajinaroundabout
authored andcommitted
refact: use a slim way to build docker image on latest code & support zgc (#2118)
* also modify shell
1 parent c8e0f0c commit 1c50cef

File tree

6 files changed

+123
-94
lines changed

6 files changed

+123
-94
lines changed

Dockerfile

Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -15,54 +15,46 @@
1515
# limitations under the License.
1616
#
1717

18-
FROM ubuntu:xenial
18+
# Dockerfile for HugeGraph Server
19+
# 1st stage: build source code
20+
FROM maven:3.9.0-eclipse-temurin-11 AS build
1921

20-
LABEL maintainer="HugeGraph Docker Maintainers <[email protected]>"
22+
COPY . /pkg
23+
WORKDIR /pkg
24+
RUN mvn package -e -B -ntp -DskipTests -Dmaven.javadoc.skip=true && pwd && ls -l
2125

22-
ENV PKG_URL https://github.com/hugegraph
26+
# 2nd stage: runtime env
27+
FROM openjdk:11-slim
28+
# TODO: get the version from the pom.xml
29+
ENV version=1.0.0
30+
COPY --from=build /pkg/apache-hugegraph-incubating-$version/ /hugegraph
31+
LABEL maintainer="HugeGraph Docker Maintainers <[email protected]>"
2332

24-
# 1. Install needed dependencies of GraphServer & RocksDB
33+
# TODO: use g1gc or zgc as default
34+
ENV JAVA_OPTS="-XX:+UnlockExperimentalVMOptions -XX:+UseContainerSupport -XX:MaxRAMPercentage=50 -XshowSettings:vm"
35+
36+
#COPY . /hugegraph/hugegraph-server
37+
WORKDIR /hugegraph/
38+
39+
# 1. Install environment
2540
RUN set -x \
2641
&& apt-get -q update \
2742
&& apt-get -q install -y --no-install-recommends --no-install-suggests \
43+
dumb-init \
44+
procps \
2845
curl \
2946
lsof \
30-
g++ \
31-
gcc \
32-
openjdk-8-jdk \
33-
&& apt-get clean
34-
# && rm -rf /var/lib/apt/lists/*
47+
&& apt-get clean \
48+
&& rm -rf /var/lib/apt/lists/*
3549

3650
# 2. Init HugeGraph Sever
37-
# (Optional) You can set the ip of github to speed up the local build
38-
# && echo "192.30.253.112 github.com\n151.101.44.249 github.global.ssl.fastly.net" >> /etc/hosts \
39-
ENV SERVER_VERSION 0.12.0
4051
RUN set -e \
41-
&& mkdir -p /root/hugegraph-server \
42-
&& curl -L -S ${PKG_URL}/hugegraph/releases/download/v${SERVER_VERSION}/hugegraph-${SERVER_VERSION}.tar.gz -o /root/server.tar.gz \
43-
&& tar xzf /root/server.tar.gz --strip-components 1 -C /root/hugegraph-server \
44-
&& rm /root/server.tar.gz \
45-
&& cd /root/hugegraph-server/ \
52+
&& pwd && cd /hugegraph/ \
4653
&& sed -i "s/^restserver.url.*$/restserver.url=http:\/\/0.0.0.0:8080/g" ./conf/rest-server.properties \
47-
&& sed -n '65p' ./bin/start-hugegraph.sh | grep "&" > /dev/null && sed -i 65{s/\&$/#/g} ./bin/start-hugegraph.sh \
48-
&& sed -n '75p' ./bin/start-hugegraph.sh | grep "exit" > /dev/null && sed -i 75{s/^/#/g} ./bin/start-hugegraph.sh \
4954
&& ./bin/init-store.sh
5055

51-
# 3. Prepare for HugeGraph Studio
52-
ENV STUDIO_VERSION 0.10.0
53-
# (Optional) You can set the ip of github to speed up the local build
54-
# && echo "192.30.253.112 github.com\n151.101.44.249 github.global.ssl.fastly.net" >> /etc/hosts \
55-
RUN set -e \
56-
&& mkdir -p /root/hugegraph-studio \
57-
&& curl -L -S ${PKG_URL}/hugegraph-studio/releases/download/v${STUDIO_VERSION}/hugegraph-studio-${STUDIO_VERSION}.tar.gz -o /root/studio.tar.gz \
58-
&& tar xzf /root/studio.tar.gz --strip-components 1 -C /root/hugegraph-studio \
59-
&& rm /root/studio.tar.gz \
60-
&& cd /root/hugegraph-studio/ \
61-
&& sed -i "s/^studio.server.host.*$/studio.server.host=0.0.0.0/g" ./conf/hugegraph-studio.properties \
62-
&& sed -i "s/^graph.server.host.*$/graph.server.host=0.0.0.0/g" ./conf/hugegraph-studio.properties
63-
64-
EXPOSE 8080 8088
65-
WORKDIR /root
66-
VOLUME /root
56+
EXPOSE 8080
57+
VOLUME /hugegraph
6758

68-
ENTRYPOINT ["./hugegraph-server/bin/start-hugegraph.sh"]
59+
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
60+
CMD ["./bin/start-hugegraph.sh", "-d false -j $JAVA_OPTS -g zgc"]

README.md

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,44 @@
1212
[![Codecov](https://codecov.io/gh/hugegraph/hugegraph/branch/master/graph/badge.svg)](https://codecov.io/gh/hugegraph/hugegraph)
1313
[![GitHub Releases Downloads](https://img.shields.io/github/downloads/hugegraph/hugegraph/total.svg)](https://github.com/hugegraph/hugegraph/releases)
1414

15-
[HugeGraph](https://hugegraph.apache.org/) is a fast-speed and highly-scalable [graph database](https://en.wikipedia.org/wiki/Graph_database). Billions of vertices and edges can be easily stored into and queried from HugeGraph due to its excellent OLTP ability. As compliance to [Apache TinkerPop 3](https://tinkerpop.apache.org/) framework, various complicated graph queries can be accomplished through [Gremlin](https://tinkerpop.apache.org/gremlin.html)(a powerful graph traversal language).
15+
[HugeGraph](https://hugegraph.apache.org/) is a fast-speed and highly-scalable [graph database](https://en.wikipedia.org/wiki/Graph_database).
16+
Billions of vertices and edges can be easily stored into and queried from HugeGraph due to its excellent OLTP ability. As compliance to [Apache TinkerPop 3](https://tinkerpop.apache.org/) framework, various complicated graph queries can be accomplished through [Gremlin](https://tinkerpop.apache.org/gremlin.html)(a powerful graph traversal language).
1617

1718
## Features
1819

19-
- Compliance to [Apache TinkerPop 3](https://tinkerpop.apache.org/), supporting [Gremlin](https://tinkerpop.apache.org/gremlin.html)
20+
- Compliance to [Apache TinkerPop 3](https://tinkerpop.apache.org/), support [Gremlin](https://tinkerpop.apache.org/gremlin.html) & [Cypher](https://en.wikipedia.org/wiki/Cypher) language
2021
- Schema Metadata Management, including VertexLabel, EdgeLabel, PropertyKey and IndexLabel
2122
- Multi-type Indexes, supporting exact query, range query and complex conditions combination query
22-
- Plug-in Backend Store Driver Framework, supporting RocksDB, Cassandra, ScyllaDB, HBase and MySQL now and easy to add other backend store driver if needed
23-
- Integration with Hadoop/Spark
23+
- Plug-in Backend Store Driver Framework, support `RocksDB`, `Cassandra`, `HBase`, `ScyllaDB`, and `MySQL/Postgre` now and easy to add other backend store driver if needed
24+
- Integration with `Flink/Spark/HDFS`, and friendly to connect other big data platforms
2425

25-
## Getting Started
26+
## Quick Start
2627

27-
The project [homepage](https://hugegraph.apache.org/docs/) contains more information on HugeGraph and provides links to **documentation**, getting-started guides and release downloads.
28+
### 1. Docker Way
2829

29-
And here are links of other repositories:
30-
1. [hugegraph-toolchain](https://github.com/apache/incubator-hugegraph-toolchain) (include loader/dashboard/tool/client)
31-
2. [hugegraph-computer](https://github.com/apache/incubator-hugegraph-computer) (graph computing system)
32-
3. [hugegraph-commons](https://github.com/apache/incubator-hugegraph-commons) (include common & rpc module)
33-
4. [hugegraph-website](https://github.com/apache/incubator-hugegraph-doc) (include doc & website code)
30+
We can use `docker run -itd --name=graph -p 8080:8080 hugegraph/hugegraph` to quickly start an inner
31+
HugeGraph server with `RocksDB` in background.
32+
33+
Optional: use `docker exec -it graph bash` to enter the container to do some operations.
34+
35+
### 2. Download Way
36+
37+
Visit [Download Page](https://hugegraph.apache.org/docs/download/download/) and refer the [doc](https://hugegraph.apache.org/docs/quickstart/hugegraph-server/#33-source-code-compilation)
38+
to download the latest release package and start the server.
39+
40+
### 3. Source Building Way
41+
42+
Visit [Source Building Page](https://hugegraph.apache.org/docs/quickstart/hugegraph-server/#33-source-code-compilation) and follow the
43+
steps to build the source code and start the server.
44+
45+
The project [doc page](https://hugegraph.apache.org/docs/) contains more information on HugeGraph
46+
and provides detailed documentation for users. (Structure / Usage / API / Configs...)
47+
48+
And here are links of other **HugeGraph** component/repositories:
49+
1. [hugegraph-toolchain](https://github.com/apache/incubator-hugegraph-toolchain) (graph **loader/dashboard/tool/client**)
50+
2. [hugegraph-computer](https://github.com/apache/incubator-hugegraph-computer) (matched **graph computing** system)
51+
3. [hugegraph-commons](https://github.com/apache/incubator-hugegraph-commons) (**common & rpc** module)
52+
4. [hugegraph-website](https://github.com/apache/incubator-hugegraph-doc) (**doc & website** code)
3453

3554
## Contributing
3655

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

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,20 @@
1515
# License for the specific language governing permissions and limitations
1616
# under the License.
1717
#
18-
abs_path() {
18+
function abs_path() {
1919
SOURCE="${BASH_SOURCE[0]}"
20-
while [ -h "$SOURCE" ]; do
20+
while [[ -h "$SOURCE" ]]; do
2121
DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
2222
SOURCE="$(readlink "$SOURCE")"
2323
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
2424
done
25-
echo "$(cd -P "$(dirname "$SOURCE")" && pwd)"
25+
cd -P "$(dirname "$SOURCE")" && pwd
2626
}
2727

2828
if [[ $# -lt 3 ]]; then
2929
echo "USAGE: $0 GREMLIN_SERVER_CONF REST_SERVER_CONF OPEN_SECURITY_CHECK"
3030
echo " e.g.: $0 conf/gremlin-server.yaml conf/rest-server.properties true"
31-
exit 1;
31+
exit 1
3232
fi
3333

3434
BIN=$(abs_path)
@@ -67,8 +67,8 @@ MIN_MEM=$((1 * 512))
6767
MIN_JAVA_VERSION=8
6868

6969
# download binary file
70-
if [[ ! -e "${CONF}/hugegraph-server.keystore" ]]; then
71-
download "${CONF}" "https://github.com/apache/hugegraph-doc/raw/binary-1.0/dist/server/hugegraph-server.keystore"
70+
if [[ ! -e "${CONF}/hugegraph-server.keystore" ]]; then
71+
download "${CONF}" "https://github.com/apache/hugegraph-doc/raw/binary-1.0/dist/server/hugegraph-server.keystore"
7272
fi
7373

7474
# Add the slf4j-log4j12 binding
@@ -77,8 +77,8 @@ CP=$(find -L $LIB -name 'log4j-slf4j-impl*.jar' | sort | tr '\n' ':')
7777
CP="$CP":$(find -L $LIB -name 'hugegraph*.jar' | sort | tr '\n' ':')
7878
# Add the remaining jars in lib.
7979
CP="$CP":$(find -L $LIB -name '*.jar' \
80-
\! -name 'hugegraph*' \
81-
\! -name 'log4j-slf4j-impl*.jar' | sort | tr '\n' ':')
80+
\! -name 'hugegraph*' \
81+
\! -name 'log4j-slf4j-impl*.jar' | sort | tr '\n' ':')
8282
# Add the jars in ext (at any subdirectory depth)
8383
CP="$CP":$(find -L $EXT -name '*.jar' | sort | tr '\n' ':')
8484
# Add the jars in plugins (at any subdirectory depth)
@@ -90,7 +90,7 @@ CP="$CP":$(find -L $PLUGINS -name '*.jar' | sort | tr '\n' ':')
9090
export CLASSPATH="${CLASSPATH:-}:$CP"
9191

9292
# Change to $BIN's parent
93-
cd "${TOP}" || exit 1;
93+
cd "${TOP}" || exit 1
9494

9595
# Find java & enable server option
9696
if [ "$JAVA_HOME" = "" ]; then
@@ -102,15 +102,15 @@ fi
102102
JAVA_VERSION=$($JAVA -version 2>&1 | head -1 | cut -d'"' -f2 | sed 's/^1\.//' | cut -d'.' -f1)
103103
if [[ $? -ne 0 || $JAVA_VERSION -lt $MIN_JAVA_VERSION ]]; then
104104
echo "Make sure the JDK is installed and the version >= $MIN_JAVA_VERSION, current is $JAVA_VERSION" \
105-
>> ${OUTPUT}
105+
>> "${OUTPUT}"
106106
exit 1
107107
fi
108108

109109
# Set Java options
110110
if [ "$JAVA_OPTIONS" = "" ]; then
111111
XMX=$(calc_xmx $MIN_MEM $MAX_MEM)
112112
if [ $? -ne 0 ]; then
113-
echo "Failed to start HugeGraphServer, requires at least ${MIN_MEM}MB free memory" >> ${OUTPUT}
113+
echo "Failed to start HugeGraphServer, requires at least ${MIN_MEM}MB free memory" >> "${OUTPUT}"
114114
exit 1
115115
fi
116116
JAVA_OPTIONS="-Xms${MIN_MEM}m -Xmx${XMX}m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=${LOGS} ${USER_OPTION}"
@@ -128,14 +128,22 @@ fi
128128

129129
# Using G1GC as the default garbage collector (Recommended for large memory machines)
130130
case "$GC_OPTION" in
131-
g1)
131+
g1|G1|g1gc)
132132
echo "Using G1GC as the default garbage collector"
133133
JAVA_OPTIONS="${JAVA_OPTIONS} -XX:+UseG1GC -XX:+ParallelRefProcEnabled \
134-
-XX:InitiatingHeapOccupancyPercent=50 -XX:G1RSetUpdatingPauseTimePercent=5"
134+
-XX:InitiatingHeapOccupancyPercent=50 \
135+
-XX:G1RSetUpdatingPauseTimePercent=5"
136+
;;
137+
zgc|ZGC)
138+
echo "Using ZGC as the default garbage collector (Only support Java 11+)"
139+
JAVA_OPTIONS="${JAVA_OPTIONS} -XX:+UseZGC -XX:+UnlockExperimentalVMOptions \
140+
-XX:ConcGCThreads=2 -XX:ParallelGCThreads=6 \
141+
-XX:ZCollectionInterval=120 -XX:ZAllocationSpikeTolerance=5 \
142+
-XX:+UnlockDiagnosticVMOptions -XX:-ZProactive"
135143
;;
136144
"") ;;
137145
*)
138-
echo "Unrecognized gc option: '$GC_OPTION', only support 'g1' now" >> ${OUTPUT}
146+
echo "Unrecognized gc option: '$GC_OPTION', only support 'G1/ZGC' now" >> ${OUTPUT}
139147
exit 1
140148
esac
141149

@@ -145,6 +153,6 @@ if [[ ${OPEN_SECURITY_CHECK} == "true" ]]; then
145153
fi
146154

147155
# Turn on security check
148-
exec ${JAVA} -Dname="HugeGraphServer" ${JVM_OPTIONS} ${JAVA_OPTIONS} \
149-
-cp ${CLASSPATH}: org.apache.hugegraph.dist.HugeGraphServer ${GREMLIN_SERVER_CONF} ${REST_SERVER_CONF} \
150-
>> ${OUTPUT} 2>&1
156+
exec ${JAVA} -Dname="HugeGraphServer" ${JVM_OPTIONS} ${JAVA_OPTIONS} -cp ${CLASSPATH}: \
157+
org.apache.hugegraph.dist.HugeGraphServer ${GREMLIN_SERVER_CONF} ${REST_SERVER_CONF} \
158+
>> ${OUTPUT} 2>&1

hugegraph-dist/src/assembly/static/bin/init-store.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,25 @@
1515
# License for the specific language governing permissions and limitations
1616
# under the License.
1717
#
18-
abs_path() {
18+
function abs_path() {
1919
SOURCE="${BASH_SOURCE[0]}"
2020
while [[ -h "$SOURCE" ]]; do
21-
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
21+
DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
2222
SOURCE="$(readlink "$SOURCE")"
23-
[[ ${SOURCE} != /* ]] && SOURCE="$DIR/$SOURCE"
23+
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
2424
done
25-
echo "$( cd -P "$( dirname "$SOURCE" )" && pwd )"
25+
cd -P "$(dirname "$SOURCE")" && pwd
2626
}
2727

28-
BIN=`abs_path`
29-
TOP="$(cd ${BIN}/../ && pwd)"
28+
BIN=$(abs_path)
29+
TOP="$(cd "${BIN}"/../ && pwd)"
3030
CONF="$TOP/conf"
3131
LIB="$TOP/lib"
3232
PLUGINS="$TOP/plugins"
3333

34-
. ${BIN}/util.sh
34+
. "${BIN}"/util.sh
3535

36-
ensure_path_writable ${PLUGINS}
36+
ensure_path_writable "${PLUGINS}"
3737

3838
if [[ -n "$JAVA_HOME" ]]; then
3939
JAVA="$JAVA_HOME"/bin/java
@@ -43,11 +43,11 @@ else
4343
EXT="$LIB:$PLUGINS"
4444
fi
4545

46-
cd ${TOP}
46+
cd "${TOP}" || exit
4747

4848
DEFAULT_JAVA_OPTIONS=""
49-
JAVA_VERSION=$($JAVA -version 2>&1 | awk 'NR==1{gsub(/"/,""); print $3}' \
50-
| awk -F'_' '{print $1}')
49+
JAVA_VERSION=$($JAVA -version 2>&1 | awk 'NR==1{gsub(/"/,""); print $3}' | awk -F'_' '{print $1}')
50+
# TODO: better not string number compare, use `bc` like github.com/koalaman/shellcheck/wiki/SC2072
5151
if [[ $? -eq 0 && $JAVA_VERSION > "1.9" ]]; then
5252
DEFAULT_JAVA_OPTIONS="--add-exports=java.base/jdk.internal.reflect=ALL-UNNAMED"
5353
fi

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

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,41 +17,45 @@
1717
#
1818
OPEN_MONITOR="false"
1919
OPEN_SECURITY_CHECK="true"
20-
VERBOSE=""
20+
DAEMON="true"
21+
#VERBOSE=""
2122
GC_OPTION=""
2223
USER_OPTION=""
2324
SERVER_STARTUP_TIMEOUT_S=30
2425

25-
while getopts "g:m:s:j:t:v" arg; do
26+
while getopts "d:g:m:s:j:t:v" arg; do
2627
case ${arg} in
28+
d) DAEMON="$OPTARG" ;;
2729
g) GC_OPTION="$OPTARG" ;;
2830
m) OPEN_MONITOR="$OPTARG" ;;
2931
s) OPEN_SECURITY_CHECK="$OPTARG" ;;
3032
j) USER_OPTION="$OPTARG" ;;
3133
t) SERVER_STARTUP_TIMEOUT_S="$OPTARG" ;;
34+
# TODO: should remove it in future (check the usage carefully)
3235
v) VERBOSE="verbose" ;;
33-
?) echo "USAGE: $0 [-g g1] [-m true|false] [-s true|false] [-j java_options] [-t timeout] [-v]" && exit 1 ;;
36+
?) echo "USAGE: $0 [-d true|false] [-g g1] [-m true|false] [-s true|false] [-j java_options]
37+
[-t timeout]" && exit 1 ;;
3438
esac
3539
done
3640

3741
if [[ "$OPEN_MONITOR" != "true" && "$OPEN_MONITOR" != "false" ]]; then
38-
echo "USAGE: $0 [-g g1] [-m true|false] [-s true|false] [-j xxx] [-v]"
42+
echo "USAGE: $0 [-d true|false] [-g g1] [-m true|false] [-s true|false] [-j java_options]"
3943
exit 1
4044
fi
4145

4246
if [[ "$OPEN_SECURITY_CHECK" != "true" && "$OPEN_SECURITY_CHECK" != "false" ]]; then
43-
echo "USAGE: $0 [-g g1] [-m true|false] [-s true|false] [-j xxx] [-v]"
47+
echo "USAGE: $0 [-d true|false] [-g g1] [-m true|false] [-s true|false] [-j java_options]"
4448
exit 1
4549
fi
4650

4751
function abs_path() {
4852
SOURCE="${BASH_SOURCE[0]}"
49-
while [ -h "$SOURCE" ]; do
50-
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
53+
while [[ -h "$SOURCE" ]]; do
54+
DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
5155
SOURCE="$(readlink "$SOURCE")"
5256
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
5357
done
54-
echo "$( cd -P "$( dirname "$SOURCE" )" && pwd )"
58+
cd -P "$(dirname "$SOURCE")" && pwd
5559
}
5660

5761
BIN=$(abs_path)
@@ -75,26 +79,32 @@ if [ ! -d "$LOGS" ]; then
7579
mkdir -p "$LOGS"
7680
fi
7781

78-
echo "Starting HugeGraphServer..."
79-
80-
${BIN}/hugegraph-server.sh ${CONF}/gremlin-server.yaml ${CONF}/rest-server.properties \
81-
${OPEN_SECURITY_CHECK} ${USER_OPTION} ${GC_OPTION} >>${LOGS}/hugegraph-server.log 2>&1 &
82+
if [[ $DAEMON == "true" ]]; then
83+
echo "Starting HugeGraphServer in daemon mode..."
84+
"${BIN}"/hugegraph-server.sh "${CONF}"/gremlin-server.yaml "${CONF}"/rest-server.properties \
85+
"${OPEN_SECURITY_CHECK}" "${USER_OPTION}" "${GC_OPTION}" >>"${LOGS}"/hugegraph-server.log 2>&1 &
86+
else
87+
echo "Starting HugeGraphServer in foreground mode..."
88+
"${BIN}"/hugegraph-server.sh "${CONF}"/gremlin-server.yaml "${CONF}"/rest-server.properties \
89+
"${OPEN_SECURITY_CHECK}" "${USER_OPTION}" "${GC_OPTION}" >>"${LOGS}"/hugegraph-server.log 2>&1
90+
fi
8291

8392
PID="$!"
8493
# Write pid to file
8594
echo "$PID" > "$PID_FILE"
8695

8796
trap 'kill $PID; exit' SIGHUP SIGINT SIGQUIT SIGTERM
8897

89-
wait_for_startup ${PID} 'HugeGraphServer' "$REST_SERVER_URL/graphs" ${SERVER_STARTUP_TIMEOUT_S} || {
98+
wait_for_startup ${PID} 'HugeGraphServer' "$REST_SERVER_URL/graphs" "${SERVER_STARTUP_TIMEOUT_S}" || {
9099
echo "See $LOGS/hugegraph-server.log for HugeGraphServer log output." >&2
91-
exit 1
100+
if [[ $DAEMON == "true" ]]; then
101+
exit 1
102+
fi
92103
}
93104
disown
94105

95106
if [ "$OPEN_MONITOR" == "true" ]; then
96-
"$BIN"/start-monitor.sh
97-
if [ $? -ne 0 ]; then
107+
if ! "$BIN"/start-monitor.sh; then
98108
echo "Failed to open monitor, please start it manually"
99109
fi
100110
echo "An HugeGraphServer monitor task has been append to crontab"

0 commit comments

Comments
 (0)