123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- #!/bin/bash
- #set -e
- if [ "$1" = "storage" ] ; then
- FASTDFS_MODE="storage"
- sed -i "s|^url_have_group_name.*$|url_have_group_name=true|g" /etc/fdfs/mod_fastdfs.conf
- else
- FASTDFS_MODE="tracker"
- fi
- if [ -n "$PORT" ] ; then
- sed -i "s|^port=.*$|port=${PORT}|g" /etc/fdfs/"$FASTDFS_MODE".conf
- if [ "$1" = "storage" ] ; then
- sed -i "s|^storage_server_port=.*$|storage_server_port=${PORT}|g" /etc/fdfs/mod_fastdfs.conf
- fi
- fi
- if [ -n "$HTTPPORT" ] ; then
- sed -i "s|80|${HTTPPORT}|g" /usr/local/nginx/conf/nginx.conf
- fi
- if [ -n "$TRACKER_SERVER" ] ; then
- sed -i "s|tracker_server=.*$|tracker_server=${TRACKER_SERVER}|g" /etc/fdfs/storage.conf
- sed -i "s|tracker_server=.*$|tracker_server=${TRACKER_SERVER}|g" /etc/fdfs/client.conf
- sed -i "s|^tracker_server=.*$|tracker_server=${TRACKER_SERVER}|g" /etc/fdfs/mod_fastdfs.conf
- fi
- if [ -n "$GROUP_NAME" ] ; then
- sed -i "s|group_name=.*$|group_name=${GROUP_NAME}|g" /etc/fdfs/storage.conf
- sed -i "s|group1|${GROUP_NAME}|g" /usr/local/nginx/conf/nginx.conf
- sed -i "s|^group_name=.*$|group_name=${GROUP_NAME}|g" /etc/fdfs/mod_fastdfs.conf
- fi
- FASTDFS_LOG_FILE="${FASTDFS_BASE_PATH}/logs/${FASTDFS_MODE}d.log"
- PID_NUMBER="${FASTDFS_BASE_PATH}/data/fdfs_${FASTDFS_MODE}d.pid"
- echo "try to start the $FASTDFS_MODE node..."
- if [ -f "$FASTDFS_LOG_FILE" ]; then
- rm "$FASTDFS_LOG_FILE"
- fi
- # start the fastdfs node.
- fdfs_${FASTDFS_MODE}d /etc/fdfs/${FASTDFS_MODE}.conf start
- if [ "$1" = "storage" ] ; then
- /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
- fi
- # wait for pid file(important!),the max start time is 5 seconds,if the pid number does not appear in 5 seconds,start failed.
- TIMES=5
- while [ ! -f "$PID_NUMBER" -a $TIMES -gt 0 ]
- do
- sleep 1s
- TIMES=`expr $TIMES - 1`
- done
- # if the storage node start successfully, print the started time.
- # if [ $TIMES -gt 0 ]; then
- # echo "the ${FASTDFS_MODE} node started successfully at $(date +%Y-%m-%d_%H:%M)"
-
- # # give the detail log address
- # echo "please have a look at the log detail at $FASTDFS_LOG_FILE"
- # # leave balnk lines to differ from next log.
- # echo
- # echo
-
-
- # # make the container have foreground process(primary commond!)
- # tail -F --pid=`cat $PID_NUMBER` /dev/null
- # # else print the error.
- # else
- # echo "the ${FASTDFS_MODE} node started failed at $(date +%Y-%m-%d_%H:%M)"
- # echo "please have a look at the log detail at $FASTDFS_LOG_FILE"
- # echo
- # echo
- # fi
- tail -f "$FASTDFS_LOG_FILE"
|