diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 717a618..0dda55d 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -23,12 +23,16 @@ jobs: script: | sudo docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} sudo docker pull ${{ secrets.DOCKER_IMAGE }}:latest + + EXISTING_CONTAINER=$(sudo docker ps --filter "publish=8080" -q) + if [ ! -z "$EXISTING_CONTAINER" ]; then + echo "Stopping and removing existing container on port 8080" + sudo docker stop $EXISTING_CONTAINER + sudo docker rm $EXISTING_CONTAINER + fi sudo docker rm -f ${{ secrets.CONTAINER_NAME }} || true + sudo docker run -d -p 8080:8080 --name ${{ secrets.CONTAINER_NAME }} \ - -e RMQ_HOST=${{ secrets.RMQ_HOST }} \ - -e RMQ_PORT=${{ secrets.RMQ_PORT }} \ - -e RMQ_USERNAME=${{ secrets.RMQ_USERNAME }} \ - -e RMQ_PASSWORD=${{ secrets.RMQ_PASSWORD }} \ -e MYSQL_URL=${{ secrets.MYSQL_URL }} \ -e MYSQL_USERNAME=${{ secrets.MYSQL_USERNAME }} \ -e MYSQL_PASSWORD=${{ secrets.MYSQL_PASSWORD }} \ diff --git a/README.MD b/README.MD new file mode 100644 index 0000000..e18e23b --- /dev/null +++ b/README.MD @@ -0,0 +1,5 @@ +
+ + + two friends gathering +
\ No newline at end of file diff --git a/src/main/java/com/example/swiftgathering_server/config/ApplicationStartup.java b/src/main/java/com/example/swiftgathering_server/config/ApplicationStartup.java new file mode 100644 index 0000000..dbb293a --- /dev/null +++ b/src/main/java/com/example/swiftgathering_server/config/ApplicationStartup.java @@ -0,0 +1,18 @@ +package com.example.swiftgathering_server.config; + +import lombok.Getter; +import org.springframework.stereotype.Component; + +import jakarta.annotation.PostConstruct; +import java.time.Instant; + +@Component +public class ApplicationStartup { + @Getter + private static Instant startTime; + + @PostConstruct + public void onStartup() { + startTime = Instant.now(); + } +} diff --git a/src/main/java/com/example/swiftgathering_server/controller/HealthController.java b/src/main/java/com/example/swiftgathering_server/controller/HealthController.java index cddee5d..ad7ffff 100644 --- a/src/main/java/com/example/swiftgathering_server/controller/HealthController.java +++ b/src/main/java/com/example/swiftgathering_server/controller/HealthController.java @@ -1,15 +1,24 @@ package com.example.swiftgathering_server.controller; +import com.example.swiftgathering_server.config.ApplicationStartup; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; +import java.time.Instant; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; + @Controller @RequestMapping("/health") public class HealthController { @GetMapping public ResponseEntity