redis kütüphanesi eklendi. #27
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Eureka Server CI/CD | |
| on: | |
| push: | |
| branches: [master] | |
| paths: | |
| - "eureka-server/**" | |
| - ".github/workflows/eureka-server-ci-cd.yml" | |
| workflow_dispatch: | |
| jobs: | |
| build-and-push: | |
| runs-on: self-hosted | |
| defaults: | |
| run: | |
| working-directory: ./eureka-server | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up JDK | |
| uses: actions/setup-java@v3 | |
| with: | |
| java-version: "21" | |
| distribution: "temurin" | |
| - name: Cache Maven packages | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.m2 | |
| key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | |
| restore-keys: ${{ runner.os }}-m2 | |
| - name: Grant execute permission for mvnw | |
| run: chmod +x mvnw | |
| - name: Build | |
| run: ./mvnw clean package -DskipTests | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v2 | |
| with: | |
| platforms: arm64 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v2 | |
| with: | |
| platforms: linux/arm64 | |
| - name: Login to DockerHub | |
| uses: docker/login-action@v2 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build and Push Docker image | |
| uses: docker/build-push-action@v4 | |
| with: | |
| context: ./eureka-server | |
| platforms: linux/arm64 | |
| push: true | |
| tags: | | |
| ${{ secrets.DOCKERHUB_USERNAME }}/eureka-server:latest-arm64 | |
| ${{ secrets.DOCKERHUB_USERNAME }}/eureka-server:${{ github.sha }}-arm64 | |
| cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/eureka-server:buildcache-arm64 | |
| cache-to: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/eureka-server:buildcache-arm64,mode=max | |
| - name: Deploy to VPS | |
| uses: appleboy/ssh-action@master | |
| with: | |
| host: ${{ secrets.VPS_HOST }} | |
| username: ${{ secrets.SSH_USERNAME }} | |
| key: ${{ secrets.SSH_PRIVATE_KEY }} | |
| script: | | |
| # Redis durumunu kontrol et ve gerekirse yeniden konfigüre et | |
| if docker ps | grep -q redis; then | |
| echo "Existing Redis container found, updating configuration for Redis Client Library..." | |
| # Redis Client kütüphanesi için gerekli konfigürasyonlar | |
| docker exec redis redis-cli -a 13579ada CONFIG SET protected-mode no | |
| docker exec redis redis-cli -a 13579ada CONFIG SET bind 0.0.0.0 | |
| docker exec redis redis-cli -a 13579ada CONFIG SET timeout 0 | |
| docker exec redis redis-cli -a 13579ada CONFIG SET tcp-keepalive 60 | |
| docker exec redis redis-cli -a 13579ada CONFIG SET maxmemory-policy volatile-lru | |
| # Redis Client kütüphanesi için performans ayarları | |
| docker exec redis redis-cli -a 13579ada CONFIG SET maxmemory "800mb" | |
| docker exec redis redis-cli -a 13579ada CONFIG SET io-threads 4 | |
| docker exec redis redis-cli -a 13579ada CONFIG SET activerehashing yes | |
| docker exec redis redis-cli -a 13579ada CONFIG SET client-output-buffer-limit "normal 0 0 0" | |
| docker exec redis redis-cli -a 13579ada CONFIG SET client-output-buffer-limit "replica 256mb 64mb 60" | |
| docker exec redis redis-cli -a 13579ada CONFIG SET hz 10 | |
| docker exec redis redis-cli -a 13579ada CONFIG SET lazyfree-lazy-eviction yes | |
| docker exec redis redis-cli -a 13579ada CONFIG SET lazyfree-lazy-expire yes | |
| # Redis bağlantısını test et | |
| if ! docker exec redis redis-cli -a 13579ada ping | grep -q "PONG"; then | |
| echo "Redis responding but failing PING test, restarting container..." | |
| docker restart redis | |
| sleep 10 | |
| # Restart sonrası tekrar ayarları uygula | |
| docker exec redis redis-cli -a 13579ada CONFIG SET protected-mode no | |
| docker exec redis redis-cli -a 13579ada CONFIG SET bind 0.0.0.0 | |
| fi | |
| else | |
| # Redis container'ı mevcut değilse başlat | |
| echo "Starting Redis container with settings optimized for Redis Client Library..." | |
| docker run -d \ | |
| --name redis \ | |
| --network craftpilot-network \ | |
| -p 6379:6379 \ | |
| -e REDIS_PASSWORD=13579ada \ | |
| --restart unless-stopped \ | |
| --memory 1g \ | |
| --memory-swap 2g \ | |
| --cpu-shares 1024 \ | |
| -v redis-data:/data \ | |
| redis:latest redis-server \ | |
| --requirepass 13579ada \ | |
| --protected-mode no \ | |
| --bind 0.0.0.0 \ | |
| --maxclients 1000 \ | |
| --tcp-backlog 511 \ | |
| --timeout 0 \ | |
| --tcp-keepalive 60 \ | |
| --maxmemory 800mb \ | |
| --maxmemory-policy volatile-lru \ | |
| --appendonly yes \ | |
| --appendfsync everysec \ | |
| --no-appendfsync-on-rewrite yes \ | |
| --auto-aof-rewrite-percentage 100 \ | |
| --auto-aof-rewrite-min-size 64mb \ | |
| --slowlog-log-slower-than 10000 \ | |
| --slowlog-max-len 128 \ | |
| --notify-keyspace-events KEA \ | |
| --io-threads 4 \ | |
| --save 900 1 \ | |
| --save 300 10 \ | |
| --save 60 10000 \ | |
| --activerehashing yes \ | |
| --lazyfree-lazy-eviction yes \ | |
| --lazyfree-lazy-expire yes \ | |
| --lazyfree-lazy-server-del yes \ | |
| --replica-lazy-flush yes \ | |
| --dynamic-hz yes \ | |
| --hz 10 \ | |
| --databases 16 \ | |
| --latency-monitor-threshold 100 | |
| fi | |
| # Redis-client-lib için Lettuce bağlantı performansını optimize et | |
| echo "Optimizing system memory and network settings for Redis Client Library..." | |
| sysctl -w vm.overcommit_memory=1 | |
| sysctl -w net.core.somaxconn=65535 | |
| sysctl -w net.ipv4.tcp_max_syn_backlog=8192 | |
| # Transparent Huge Pages devre dışı bırak (Redis performansı için) | |
| echo never > /sys/kernel/mm/transparent_hugepage/enabled || true | |
| # Redis'in hazır olmasını bekle | |
| echo "Waiting for Redis to be ready..." | |
| MAX_ATTEMPTS=30 | |
| ATTEMPT=0 | |
| while [ $ATTEMPT -lt $MAX_ATTEMPTS ]; do | |
| if docker exec redis redis-cli -a 13579ada ping | grep -q "PONG"; then | |
| echo "Redis is ready!" | |
| break | |
| fi | |
| ATTEMPT=$((ATTEMPT+1)) | |
| echo "Waiting for Redis... Attempt $ATTEMPT/$MAX_ATTEMPTS" | |
| sleep 2 | |
| done | |
| # Redis hazır olmazsa uyarı yap ama devam et | |
| if [ $ATTEMPT -eq $MAX_ATTEMPTS ]; then | |
| echo "WARNING: Redis may not be properly configured, but continuing with Eureka deployment" | |
| fi | |
| # Eureka Server'ı başlat | |
| echo "Starting Eureka Server..." | |
| docker pull ${{ secrets.DOCKERHUB_USERNAME }}/eureka-server:latest-arm64 | |
| docker stop eureka-server || true | |
| docker rm eureka-server || true | |
| docker run -d \ | |
| --name eureka-server \ | |
| --network craftpilot-network \ | |
| --restart unless-stopped \ | |
| -p 8761:8761 \ | |
| --memory 600m \ | |
| --memory-swap 1g \ | |
| --cpu-shares 512 \ | |
| -e SPRING_PROFILES_ACTIVE=prod \ | |
| -e SERVER_PORT=8761 \ | |
| -e EUREKA_CLIENT_REGISTER_WITH_EUREKA=false \ | |
| -e EUREKA_CLIENT_FETCH_REGISTRY=false \ | |
| -e SPRING_SECURITY_USER_NAME=craftpilot \ | |
| -e SPRING_SECURITY_USER_PASSWORD=13579ada \ | |
| -e EUREKA_SERVER_ENABLE_SELF_PRESERVATION=false \ | |
| -e EUREKA_SERVER_EVICTION_INTERVAL_TIMER_IN_MS=3000 \ | |
| -e MANAGEMENT_ENDPOINTS_WEB_EXPOSURE_INCLUDE=health,info,metrics,prometheus \ | |
| -e MANAGEMENT_ENDPOINT_HEALTH_SHOW_DETAILS=always \ | |
| -e JAVA_OPTS="-XX:+UseContainerSupport -XX:MaxRAMPercentage=75.0 -XX:+UseG1GC -Xms256m -Xmx512m" \ | |
| ${{ secrets.DOCKERHUB_USERNAME }}/eureka-server:latest-arm64 | |
| # Health check - port 8761'i kontrol et | |
| echo "Checking Eureka Server health..." | |
| for i in {1..30}; do | |
| HEALTH_STATUS=$(curl -s -u craftpilot:13579ada http://localhost:8761/actuator/health || echo "Failed to connect") | |
| if echo "$HEALTH_STATUS" | grep -q "UP"; then | |
| echo "Eureka Server is healthy" | |
| exit 0 | |
| fi | |
| if [ $i -eq 15]; then | |
| echo "Mid-point container logs:" | |
| docker logs eureka-server | |
| fi | |
| echo "Waiting for Eureka Server to be healthy... (attempt $i/30)" | |
| sleep 10 | |
| done | |
| echo "Eureka Server failed to become healthy" | |
| docker logs eureka-server | |
| exit 1 |