gemercheung 3 years ago
parent
commit
2c2a423f47
1 changed files with 39 additions and 0 deletions
  1. 39 0
      start2.sh

+ 39 - 0
start2.sh

@@ -0,0 +1,39 @@
+#!/usr/bin/env bash
+
+cp .env.production .env
+
+source .env
+
+echo "port: $PORT"
+echo "port1: $PORT1"
+echo "port2: $PORT2"
+echo "SOCKET_PORT: $SOCKET_PORT"
+echo "CONTAINER_NAME: $CONTAINER_NAME"
+echo "CONTAINER_NAME1: $CONTAINER_NAME1"
+echo "CONTAINER_NAME2: $CONTAINER_NAME2"
+echo "SOCKET_PATH: $SOCKET_PATH"
+
+
+if [ ! "$(docker ps -q -f name=$CONTAINER_NAME))" ]; then
+    if [ "$(docker ps -aq -f status=exited -f name=$CONTAINER_NAME))" ]; then
+        # cleanup
+        docker rm $CONTAINER_NAME -f
+        docker rm $CONTAINER_NAME1 -f
+        docker rm $CONTAINER_NAME2 -f
+        # docker rm "$CONTAINER_NAME-redis" -f
+    fi
+    # run your container
+    echo "no container and docker-compose up"
+    docker-compose up --force-recreate -d
+else
+    if [ "$(docker ps -aq -f status=running -f name=$CONTAINER_NAME))" ]; then
+        # cleanup
+        docker rm $CONTAINER_NAME -f
+        docker rm $CONTAINER_NAME1 -f
+        docker rm $CONTAINER_NAME2 -f
+        #  docker rm "$CONTAINER_NAME-redis" -f
+    fi
+    echo "has container and docker-compose up"
+    docker-compose up --force-recreate -d
+    
+fi