Skip to content

Commit a6d392f

Browse files
t-gittritesh-loanstreet
authored andcommitted
docker-pull - run save logs at post-push step
1 parent d2d14d7 commit a6d392f

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

scripts/defaults.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ PUSH=git-bare
1111
PACKAGE=git
1212
RESTART_COMMAND="sh deploy/run.sh restart"
1313
DEPLOYMENT_DIR='$HOME/sites/$SERVICE_NAME/$PROJECT_ENVIRONMENT'
14+
LOG_DIR=$DEPLOYMENT_DIR/shared/logs
1415
RELEASE_COUNT=5
1516
DOCKER_COMPOSE_OPTS=""
1617
DOCKER_REGISTRY=https://dockerhub.finology.com.my

steps/post_push/lib/docker-pull-resources/post-receive-hook

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,16 @@ done
1616

1717
cd $DEPLOY_DIR/current && docker-compose -f docker-compose.yml up -d --no-build
1818

19+
if [ -n "$LOG_DIR" ]; then
20+
if [ ! -d "$LOG_DIR" ]; then
21+
info "Creating Log Directory; $LOG_DIR"
22+
mkdir -p "$LOG_DIR"
23+
fi
24+
25+
if [ -d "$LOG_DIR" ]; then
26+
info "Saving Logs To $LOG_DIR/$SERVICE_NAME.log"
27+
docker-compose -f docker-compose.yml logs -f >> "$LOG_DIR/$SERVICE_NAME.log" 2>&1 &
28+
fi
29+
fi
30+
1931
post_startup

steps/push/lib/git-bare-resources/post-receive-utils.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,7 @@ stop_current_container() {
1919
CURRENT_DOCKER_COMPOSE="$DEPLOYMENT_DIR/current/docker-compose.yml"
2020
CURRENT_DIR=$(pwd)
2121
if [ -f "$CURRENT_DOCKER_COMPOSE" ]; then
22-
CURRENT_LOG_FOLDER="$DEPLOYMENT_DIR/shared/logs"
23-
mkdir -p "$CURRENT_LOG_FOLDER"
2422
cd "$DEPLOYMENT_DIR/current"
25-
if [ -d "$CURRENT_LOG_FOLDER" ]; then
26-
docker-compose logs 2>&1 >> "$CURRENT_LOG_FOLDER/$SERVICE_NAME.log"
27-
fi
2823
docker-compose rm -sf
2924
cd "$CURRENT_DIR"
3025
fi

0 commit comments

Comments
 (0)