-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathstop-and-run-docker.sh
44 lines (35 loc) · 1.17 KB
/
stop-and-run-docker.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
set -x
PROJECT_NAME=$1
BUILD_ENV=$2
DIR_NAME="$(dirname $0)"
CURRENT_DIR="$(cd $DIR_NAME; pwd)"
# Source config
source "$CURRENT_DIR/settings.$BUILD_ENV"
# Docker folder
DOCKER_PROJECT=$PACKAGE_PROJECT/projects/$PROJECT_NAME/docker
# Run
DEPLOY_USER_AT_HOST=$DEPLOY_DOCKER_USER@$DEPLOY_DOCKER_HOST
<<<<<<< HEAD
=======
ssh $DEPLOY_USER_AT_HOST "service $PROJECT_NAME stop | true"
>>>>>>> f7f2029bf9c65699c35e2d32ffe21d70422844cb
ssh $DEPLOY_USER_AT_HOST "docker stop $PROJECT_NAME | true"
ssh $DEPLOY_USER_AT_HOST "docker kill $PROJECT_NAME | true"
ssh $DEPLOY_USER_AT_HOST "docker rm $PROJECT_NAME | true"
ssh $DEPLOY_USER_AT_HOST "cd $DOCKER_PROJECT; ./run_docker $PROJECT_NAME"
sleep $WAIT_RUN_TIME
# Check if it is running
ssh $DEPLOY_USER_AT_HOST "docker ps | grep $PROJECT_NAME:latest"
RUN_CHECK=$?
if [ $RUN_CHECK == 1 ]; then
CONTAINER=$(ssh $DEPLOY_USER_AT_HOST "docker ps -a | grep $PROJECT_NAME:latest | head -n1 | cut -d' ' -f1")
if [ ! -z "$CONTAINER" ]; then
ssh $DEPLOY_USER_AT_HOST "docker logs $CONTAINER"
fi
exit 1
fi
<<<<<<< HEAD
=======
ssh $DEPLOY_USER_AT_HOST "service $PROJECT_NAME start | true"
>>>>>>> f7f2029bf9c65699c35e2d32ffe21d70422844cb