Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dist): support pre-load test graph data in docker container #2241

Merged
merged 11 commits into from
Aug 28, 2023
35 changes: 35 additions & 0 deletions hugegraph-dist/README.md
aroundabout marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Deploy Hugegraph server with docker compose(WIP)

## 1. Deploy

We can use `docker-compose up -d` to quickly start an inner HugeGraph server with RocksDB in background.

The docker-compose.yaml is below:

```yaml
version: '3'
services:
graph:
image: hugegraph/hugegraph
ports:
- 18080:8080
```

## 2. Create Sample Graph on Server Startup

If you want to pre-load some data or graphs in container, you can set the env `PRELOAD=ture`

If you want to customize the pre-loaded data, please mount the the groovy scripts
aroundabout marked this conversation as resolved.
Show resolved Hide resolved

```yaml
version: '3'
services:
graph:
image: hugegraph/hugegraph
environment:
- PRELOAD=true
volumes:
- /path/to/yourscript:/hugegraph/scripts/example-preload.groovy
ports:
- 18080:8080
```
15 changes: 13 additions & 2 deletions hugegraph-dist/src/assembly/static/bin/start-hugegraph.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ BIN=$(abs_path)
TOP="$(cd "$BIN"/../ && pwd)"
CONF="$TOP/conf"
LOGS="$TOP/logs"
SCRIPTS="$TOP/scripts"
PID_FILE="$BIN/pid"

. "$BIN"/util.sh
Expand All @@ -79,13 +80,23 @@ if [ ! -d "$LOGS" ]; then
mkdir -p "$LOGS"
fi

GREMLIN_SERVER_CONF="gremlin-server.yaml"
if [[ $PRELOAD == "true" ]]; then
aroundabout marked this conversation as resolved.
Show resolved Hide resolved
GREMLIN_SERVER_CONF="gremlin-server-preload.yaml"
EXAMPLE_SCRPIT="example-preload.groovy"
cp "${CONF}"/gremlin-server.yaml "${CONF}/${GREMLIN_SERVER_CONF}"
cp "${SCRIPTS}"/example.groovy "${SCRIPTS}/${EXAMPLE_SCRPIT}"
sed -i -e "s/empty-sample.groovy/$EXAMPLE_SCRPIT/g" "${CONF}/${GREMLIN_SERVER_CONF}"
sed -i -e '/registerRocksDB/d; /serverStarted/d' "${SCRIPTS}/${EXAMPLE_SCRPIT}"
fi

if [[ $DAEMON == "true" ]]; then
echo "Starting HugeGraphServer in daemon mode..."
"${BIN}"/hugegraph-server.sh "${CONF}"/gremlin-server.yaml "${CONF}"/rest-server.properties \
"${BIN}"/hugegraph-server.sh "${CONF}/${GREMLIN_SERVER_CONF}" "${CONF}"/rest-server.properties \
"${OPEN_SECURITY_CHECK}" "${USER_OPTION}" "${GC_OPTION}" >>"${LOGS}"/hugegraph-server.log 2>&1 &
else
echo "Starting HugeGraphServer in foreground mode..."
"${BIN}"/hugegraph-server.sh "${CONF}"/gremlin-server.yaml "${CONF}"/rest-server.properties \
"${BIN}"/hugegraph-server.sh "${CONF}/${GREMLIN_SERVER_CONF}" "${CONF}"/rest-server.properties \
"${OPEN_SECURITY_CHECK}" "${USER_OPTION}" "${GC_OPTION}" >>"${LOGS}"/hugegraph-server.log 2>&1
fi

Expand Down