From b4a763a8839e0b03d9d8b0cc688bbbb31d20eb71 Mon Sep 17 00:00:00 2001 From: Deckard Date: Fri, 3 Oct 2025 22:05:39 -0400 Subject: [PATCH] post-install updates --- docker-compose-azerothcore-services.yml | 5 ++- readme.md | 35 ++++++++++++++++- scripts/auto-post-install.sh | 51 +++++++++++++++++++++++-- 3 files changed, 85 insertions(+), 6 deletions(-) diff --git a/docker-compose-azerothcore-services.yml b/docker-compose-azerothcore-services.yml index e0921d8..6ebaf0d 100644 --- a/docker-compose-azerothcore-services.yml +++ b/docker-compose-azerothcore-services.yml @@ -1106,6 +1106,7 @@ services: - ${STORAGE_PATH}/config:/azerothcore/config - ${STORAGE_PATH}/install-markers:/install-markers - .:/project + - /var/run/docker.sock:/var/run/docker.sock:rw working_dir: /project environment: MYSQL_HOST: ${CONTAINER_MYSQL} @@ -1119,6 +1120,8 @@ services: SERVER_ADDRESS: ${SERVER_ADDRESS} REALM_PORT: ${REALM_PORT} NETWORK_NAME: ${NETWORK_NAME} + CONTAINER_AUTHSERVER: ${CONTAINER_AUTHSERVER} + CONTAINER_WORLDSERVER: ${CONTAINER_WORLDSERVER} depends_on: - ac-modules command: @@ -1127,7 +1130,7 @@ services: - | # Install required packages echo "đŸ“Ļ Installing required packages..." - apk add --no-cache bash curl + apk add --no-cache bash curl docker-cli # Download post-install script from GitHub (fallback to local for testing) echo "đŸ“Ĩ Downloading auto post-install script..." diff --git a/readme.md b/readme.md index 9196a3a..0d385fa 100644 --- a/readme.md +++ b/readme.md @@ -18,6 +18,7 @@ This project is a Docker/Podman implementation based on: - **Multi-Runtime Support**: Works with both Docker and Podman - **Automated Database Initialization**: Complete schema import and setup automation - **Comprehensive Health Checks**: Built-in service monitoring and restart policies +- **Automated Service Restart**: Post-install automatically restarts services with Docker/Podman support - **Automated Backup System**: Scheduled backups with configurable retention - **Production-Ready Security**: Advanced security configurations and best practices @@ -69,6 +70,7 @@ This project provides a production-ready AzerothCore deployment using Docker/Pod - ✅ **Fully Containerized**: All components run in isolated containers - ✅ **Automated Setup**: Database creation, schema import, and configuration handled automatically +- ✅ **Auto-Restart Services**: Post-install automatically restarts authserver/worldserver (Docker/Podman compatible) - ✅ **Playerbot Integration**: AI-controlled bots for solo/small group play - ✅ **Eluna Support**: Lua scripting for custom content - ✅ **Automated Backups**: Scheduled database backups with retention policies @@ -379,10 +381,41 @@ docker logs ac-post-install -f # 2. Wait for MySQL and configuration files to be ready # 3. Update .conf files with production database settings # 4. Update realmlist table with server address and port -# 5. Restart services to apply changes +# 5. Automatically restart authserver and worldserver to apply changes # 6. Create a completion marker to prevent re-execution ``` +#### Automatic Service Restart + +The post-install system includes **automatic service restart functionality** with support for both Docker and Podman: + +**Container Runtime Detection**: +- đŸŗ **Docker**: Automatically detects Docker daemon and uses Docker CLI +- đŸĻ­ **Podman**: Falls back to Podman CLI if Docker unavailable +- âš ī¸ **Graceful fallback**: Skips restart if no runtime detected (continues other tasks) + +**Restart Process**: +```bash +🔄 Restarting authserver and worldserver to pick up new configuration... +đŸŗ Detected Docker runtime +🔄 Restarting authserver container: ac-authserver +✅ Authserver restarted successfully +🔄 Restarting worldserver container: ac-worldserver +✅ Worldserver restarted successfully +✅ Service restart completed +``` + +**Requirements**: +- **Docker socket access**: Container has `/var/run/docker.sock` mounted +- **Container runtime**: Docker or Podman available in container +- **Environment variables**: `CONTAINER_AUTHSERVER` and `CONTAINER_WORLDSERVER` defined + +**Benefits**: +- ✅ **Immediate effect**: Configuration changes applied instantly +- ✅ **No manual intervention**: Fully automated restart process +- ✅ **Cross-platform**: Works with Docker Desktop, Podman, and cloud environments +- ✅ **Graceful shutdown**: Services shut down cleanly before restart + #### Manual Post-Installation (Optional) If you need to run post-installation manually or troubleshoot: diff --git a/scripts/auto-post-install.sh b/scripts/auto-post-install.sh index 5897822..5e8584d 100755 --- a/scripts/auto-post-install.sh +++ b/scripts/auto-post-install.sh @@ -104,12 +104,55 @@ else exit 1 fi - # Step 3: Note about service restart + # Step 3: Restart services to apply changes echo "" - echo "â„šī¸ Step 3: Service restart note..." + echo "â„šī¸ Step 3: Restarting services to apply changes..." echo "📝 Configuration changes have been applied to files" - echo "💡 Services will automatically restart if needed during next deployment" - echo "✅ Post-install configuration completed - services will pick up changes on next restart" + echo "🔄 Restarting authserver and worldserver to pick up new configuration..." + + # Detect container runtime (Docker or Podman) + CONTAINER_CMD="" + if command -v docker >/dev/null 2>&1; then + # Check if we can connect to Docker daemon + if docker version >/dev/null 2>&1; then + CONTAINER_CMD="docker" + echo "đŸŗ Detected Docker runtime" + fi + fi + + if [ -z "$CONTAINER_CMD" ] && command -v podman >/dev/null 2>&1; then + # Check if we can connect to Podman + if podman version >/dev/null 2>&1; then + CONTAINER_CMD="podman" + echo "đŸĻ­ Detected Podman runtime" + fi + fi + + if [ -z "$CONTAINER_CMD" ]; then + echo "âš ī¸ No container runtime detected (docker/podman) - skipping restart" + else + # Restart authserver + if [ -n "$CONTAINER_AUTHSERVER" ]; then + echo "🔄 Restarting authserver container: $CONTAINER_AUTHSERVER" + if $CONTAINER_CMD restart "$CONTAINER_AUTHSERVER" 2>/dev/null; then + echo "✅ Authserver restarted successfully" + else + echo "âš ī¸ Failed to restart authserver (may not be running yet)" + fi + fi + + # Restart worldserver + if [ -n "$CONTAINER_WORLDSERVER" ]; then + echo "🔄 Restarting worldserver container: $CONTAINER_WORLDSERVER" + if $CONTAINER_CMD restart "$CONTAINER_WORLDSERVER" 2>/dev/null; then + echo "✅ Worldserver restarted successfully" + else + echo "âš ī¸ Failed to restart worldserver (may not be running yet)" + fi + fi + fi + + echo "✅ Service restart completed" # Create completion marker echo "$(date)" > /install-markers/post-install-completed