Skip to content

Commit

Permalink
fastdfs优化FASTDFS_MODE
Browse files Browse the repository at this point in the history
  • Loading branch information
Felix2yu committed Feb 21, 2024
1 parent c5f11ea commit 498c771
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
8 changes: 4 additions & 4 deletions fastdfs/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@ RUN git clone -b $FASTDFS_VERSION https://github.com/happyfish100/fastdfs.git &&
cd fastdfs && \
./make.sh

FROM debian:stable
FROM debian:stable-slim

LABEL org.opencontainers.image.source = "https://github.com/Felix2yu/docker_build" \
maintainer="Felix2yu <yufei.im@icloud.com>" \
org.opencontainers.image.authors="Felix2yu <yufei.im@icloud.com>"

ENV FASTDFS_PATH=/opt/fdfs \
FASTDFS_BASE_PATH=/data/fdfs \
TZ=Asia/Shanghai
TZ=Asia/Shanghai \
FASTDFS_MODE=

COPY --from=builder ${FASTDFS_PATH} ${FASTDFS_PATH}
COPY entrypoint.sh /usr/bin/
Expand All @@ -41,5 +42,4 @@ RUN chmod +x /usr/bin/entrypoint.sh && \
EXPOSE 22122 23000
VOLUME ["$FASTDFS_BASE_PATH","/etc/fdfs"]

ENTRYPOINT ["/usr/bin/entrypoint.sh"]
CMD ["tracker"]
ENTRYPOINT ["/usr/bin/entrypoint.sh"]
27 changes: 13 additions & 14 deletions fastdfs/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,6 @@ function fdfs_start() {
FASTDFS_LOG_FILE="${FASTDFS_BASE_PATH}/logs/${FASTDFS_MODE}d.log"
PID_NUMBER="${FASTDFS_BASE_PATH}/data/fdfs_${FASTDFS_MODE}d.pid"

if [ "$1" = "monitor" ] ; then
fdfs_monitor /etc/fdfs/client.conf
exit 0
elif [ "$1" = "storage" ] ; then
FASTDFS_MODE="storage"
elif [ "$1" = "tracker" ] ; then
FASTDFS_MODE="tracker"
else
echo "No mode parameters were received."
exit 1
fi

echo "try to start the $FASTDFS_MODE node..."
fdfs_${FASTDFS_MODE}d /etc/fdfs/${FASTDFS_MODE}.conf stop
if [ -f "$FASTDFS_LOG_FILE" ]; then
Expand Down Expand Up @@ -49,8 +37,19 @@ function health_check() {
done
}

fdfs_start
health_check &
if [ "$1" = "monitor" ] ; then
fdfs_monitor /etc/fdfs/client.conf
exit 0
elif [ "$FASTDFS_MODE" = "storage" ] ; then
fdfs_start
health_check &
elif [ "$FASTDFS_MODE" = "tracker" ] ; then
fdfs_start
health_check &
else
echo "No mode parameters were received."
exit 1
fi

# wait for pid file(important!),the max start time is 30 seconds,if the pid number does not appear in 30 seconds,start failed.
TIMES=30
Expand Down

0 comments on commit 498c771

Please sign in to comment.