我创建了一个定制的坞映像,以便启动包装器脚本来加载初始数据。当我第一次启动这个容器时,有时会失败,但我想是缓存了一些东西,或者我没有足够的时间等待neo4j的启动。
当我停止容器并重新启动它时,问题就出现了。它下载插件,然后它似乎挂起,它不能使进程到前台。
./wrapper.sh: line 57: fg: job has terminated In /logs/debug.log当我重新启动容器时没有日志。所以很难理解到底发生了什么。有什么许可吗?
这里是我的包装文件
#!/bin/bash
# THANK YOU! Special shout-out to @marcellodesales on GitHub
# https://github.com/marcellodesales/neo4j-with-cypher-seed-docker/blob/master/wrapper.sh for such a great example script
# Log the info with the same format as NEO4J outputs
log_info() {
# https://www.howtogeek.com/410442/how-to-display-the-date-and-time-in-the-linux-terminal-and-use-it-in-bash-scripts/
# printf '%s %s\n' "$(date -u +"%Y-%m-%d %H:%M:%S:%3N%z") INFO Wrapper: $1" # Display UTC time
printf '%s %s\n' "$(date +"%Y-%m-%d %H:%M:%S:%3N%z") INFO Wrapper: $1" # Display local time (PST/PDT)
return
}
# Adapted from https://github.com/neo4j/docker-neo4j/issues/166#issuecomment-486890785
# Alpine is not supported anymore, so this is newer
# Refactoring: Marcello.deSales+github@gmail.com
# turn on bash's job control
# https://stackoverflow.com/questions/11821378/what-does-bashno-job-control-in-this-shell-mean/46829294#46829294
set -m
# Start the primary process and put it in the background
/docker-entrypoint.sh neo4j &
# Wait for Neo4j
log_info "Checking to see if Neo4j has started at http://${DB_HOST}:${DB_PORT}..."
wget --quiet --tries=20 --waitretry=10 -O /dev/null http://${DB_HOST}:${DB_PORT}
log_info "Neo4j has started "
log_info "Importing data with auth ${NEO4J_AUTH}"
# Import data
log_info "Loading and importing Cypher file(s)..."
for cypherFile in /var/lib/neo4j/import/*.data.cypher; do
[ -f "$cypherFile" ] || break
log_info "Running cypher ${cypherFile}"
cat ${cypherFile} | bin/cypher-shell -u ${NEO4J_USER} -p ${NEO4J_PASSWORD} --fail-fast --format plain
log_info "Renaming import file ${cypherFile}"
mv ${cypherFile} ${cypherFile}.applied
done
log_info "Finished loading data"
log_info "Running startup cypher script..."
for cypherFile in /var/lib/neo4j/import/*.startup.cypher; do
[ -f "$cypherFile" ] || break
log_info "Running cypher ${cypherFile}"
cat ${cypherFile} | bin/cypher-shell -u ${NEO4J_USER} -p ${NEO4J_PASSWORD} --fail-fast --format plain
done
log_info "Finished running startup script"
# now we bring the primary process back into the foreground
# and leave it there
fg %1这是我的文件
FROM neo4j
ENV NEO4J_USER=neo4j
ENV NEO4J_PASSWORD=s3cr3t
ENV NEO4J_AUTH=${NEO4J_USER}/${NEO4J_PASSWORD}
ENV NEO4JLABS_PLUGINS='["apoc", "graph-data-science"]'
ENV NEO4J_HOME='/var/lib/neo4j'
ENV DB_HOST='localhost'
ENV DB_PORT=7474
ENV NEO4J_dbms_logs_debug_level='DEBUG'
ENV NEO4J_dbms_logs_user_stdout__enabled='true'
EXPOSE 7474 7473 7687
COPY initial-data/ /var/lib/neo4j/import/
COPY ./docker-scripts/wrapper.sh wrapper.sh
ENTRYPOINT ["./wrapper.sh"]你知道如何解决这个问题吗?或者至少知道出了什么问题?
发布于 2022-08-21 12:37:15
这似乎发生在最新的版本,当我切换到了新4j:4.2,然后它开始正常工作。
我试图运行干净的映像,但使用包装器脚本,在我看来,4.4.10在关闭时存在一些问题,可能留下了一些不一致的状态
https://stackoverflow.com/questions/73370705
复制相似问题