Skip to content

Commit

Permalink
fix: resolve the issue of local startup failure.
Browse files Browse the repository at this point in the history
  • Loading branch information
hu3rror committed Jun 23, 2024
1 parent e00fd18 commit 51dd005
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ RUN if [ "$USE_MEMOGRAM" = "1" ]; then \
fi

# Define ENV
ENV DB_PATH="/var/opt/memos/memos_prod.db"
EXPOSE 5230
ENV MEMOS_PORT="5230"
ENV SERVER_ADDR=dns:localhost:$MEMOS_PORT
EXPOSE $MEMOS_PORT
ENV SERVER_ADDR=dns:localhost:5230
ENV DB_PATH="/var/opt/memos/memos_prod.db"

# Run memos with litestream (Default WORKDIR is `/usr/local/memos/`)
CMD ["./run.sh"]
16 changes: 10 additions & 6 deletions scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,20 @@ if use_litestream; then
else
echo "No local database found, attempt to restore the latest version of database from S3/B2."
litestream restore -if-replica-exists "$DB_PATH"
echo "Database restored successfully!"
if [ ! -f "$DB_PATH" ]; then
echo "Failed to restore the latest version of the database from S3/B2."
echo "It seems that you are using memos for the first time. Now, if memos starts successfully, it will create a new database."
fi
fi
fi

# Start Litestream with the Memos service as the subprocess.
echo "Starting litestream replicate with the Memos service as the subprocess."
litestream replicate -exec "./memos" &

# Start Memogram if the required environment variables are set.
if use_memogram; then
if ! use_memogram; then
# Start Litestream with the Memos service as the subprocess.
echo "Starting litestream replicate with the Memos service as the subprocess."
exec litestream replicate -exec "./memos"
else
exec litestream replicate -exec "./memos" &
timeout=30
while [ $timeout -gt 0 ]; do
if pgrep -x "memos" >/dev/null && [ -f "$DB_PATH" ]; then
Expand Down

0 comments on commit 51dd005

Please sign in to comment.