Skip to content

Instantly share code, notes, and snippets.

@yunghoy
Created January 3, 2017 06:28
Show Gist options
  • Save yunghoy/9569afda9d04f0d4f0f15945cdd2b00a to your computer and use it in GitHub Desktop.
Save yunghoy/9569afda9d04f0d4f0f15945cdd2b00a to your computer and use it in GitHub Desktop.
shell script
#!/bin/bash
CONTAINER=${STREAM}_${ISLAND_NAME}_1
CONTAINER_ID=$(docker ps -a | grep ${CONTAINER} | awk '{print $1}')
# exception check if the container exists
if [ ! ${CONTAINER_ID} ]; then
echo "There is no ${CONTAINER}"
exit 1
fi
echo "${CONTAINER} has the ID ${CONTAINER_ID}..."
# Garbage Collecting
echo "Garbage Collecting..."
sudo rm -f *.json
#sudo find . -type f -name '*.log' -delete # deleting DediLogs
#docker exec dl_circuit_1 bash -c "tar cvfz /root/DediLog.tar.gz /root/.fb"
#docker cp dl_circuit_1:/root/DediLog.tar.gz ./DediLog.tar.gz
# the console log file
LOGPATH=$(docker inspect ${CONTAINER} | grep LogPath | awk -F '\"' '{print $4}')
TARGETFILE=$(echo ${LOGPATH} | awk -F '/' '{print $6}')
sudo cp ${LOGPATH} ${TARGETFILE}.json
#sudo chmod 777 ${LOGPATH}
sudo chown -R eass-build *
# 뭔가 json 파일에 처리가 필요하면 여기서 해주세요.
pushd Edge.DL.DedicatedServer/Server/Logs > /dev/null
LIST=$(ls -trl | grep Runtime | sed -E "s/.*(RuntimeLog.*\.log)/\1/")
CNT=0
echo ${LIST}
for file in ${LIST}; do
echo "${file}"
((CNT++))
done
echo "Total Files: ${CNT}"
for file in ${LIST}; do
if [ ${CNT} -le 1 ];then break; fi
echo "Sending the file ${file}..."
# 여기 보낼 명령어
echo "Removing the file ${file}..."
# 아래 sharp 주석 제거.
#rm -f ${file}
((CNT--))
done
popd > /dev/null
# Nginx
if [ $(docker ps -a | grep CircuitLogNginx | awk '{print $1}') ]; then
docker rm -f CircuitLogNginx
fi
docker run --name CircuitLogNginx \
-v /home/eass-build/CircuitLogRoot:/usr/share/nginx/html:ro \
-v /home/eass-build/CircuitLogRoot/default.conf:/etc/nginx/conf.d/default.conf:ro \
-p 80:80 \
-d nginx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment