diff --git a/.github/workflows/buildwindowsimage.yml b/.github/workflows/buildwindowsimage.yml index fa4f705..394605b 100644 --- a/.github/workflows/buildwindowsimage.yml +++ b/.github/workflows/buildwindowsimage.yml @@ -15,11 +15,6 @@ jobs: steps: - uses: actions/checkout@v2.3.4 - - name: Install NET 9 - uses: actions/setup-dotnet@v4.0.1 - with: - dotnet-version: '9.0.x' - - name: Get the version id: get_version uses: battila7/get-version-action@v2 diff --git a/.github/workflows/createrelease.yml b/.github/workflows/createrelease.yml index 0ccd803..056e0a0 100644 --- a/.github/workflows/createrelease.yml +++ b/.github/workflows/createrelease.yml @@ -5,7 +5,7 @@ on: types: [published] jobs: - buildlinux: + build: name: "Release" env: ASPNETCORE_ENVIRONMENT: "Production" @@ -15,11 +15,6 @@ jobs: steps: - uses: actions/checkout@v2.3.4 - - name: Install NET 9 - uses: actions/setup-dotnet@v4.0.1 - with: - dotnet-version: '9.0.x' - - name: Get the version id: get_version run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} @@ -46,7 +41,7 @@ jobs: - name: Publish API if: ${{ github.event.release.prerelease == false }} - run: dotnet publish "TestHosts\TestHosts\TestHosts.csproj" --configuration Release --output publishOutput -r linux-x64 --self-contained + run: dotnet publish "TestHosts\TestHosts\TestHosts.csproj" --configuration Release --output publishOutput -r win-x64 --self-contained - name: Build Release Package run: | @@ -60,8 +55,8 @@ jobs: path: testhosts.zip deploystaging: - runs-on: [stagingserver, linux] - needs: buildlinux + runs-on: [stagingserver, windows] + needs: build environment: staging name: "Deploy to Staging" @@ -70,77 +65,31 @@ jobs: uses: actions/download-artifact@v4.1.8 with: name: testhosts - path: /tmp/testhosts # Download to a temporary directory - - name: Remove existing service (if applicable) + - name: Remove existing Windows service run: | - SERVICE_NAME="testhosts" - if systemctl is-active --quiet "$SERVICE_NAME"; then - echo "Stopping existing service..." - sudo systemctl stop "$SERVICE_NAME" - fi - if systemctl is-enabled --quiet "$SERVICE_NAME"; then - echo "Disabling existing service..." - sudo systemctl disable "$SERVICE_NAME" - fi - if [ -f "/etc/systemd/system/${SERVICE_NAME}.service" ]; then - echo "Removing existing service unit file..." - sudo rm "/etc/systemd/system/${SERVICE_NAME}.service" - sudo systemctl daemon-reload - fi + $serviceName = "Transaction Processing - Test Hosts" + # Check if the service exists + if (Get-Service -Name $serviceName -ErrorAction SilentlyContinue) { + Stop-Service -Name $serviceName + sc.exe delete $serviceName + } - name: Unzip the files run: | - sudo mkdir -p /opt/txnproc/transactionprocessing/testhosts - sudo unzip -o /tmp/testhosts/testhosts.zip -d /opt/txnproc/transactionprocessing/testhosts - - # IMPORTANT: Add a step to ensure the .NET runtime is installed on the server - # This assumes it's not already there. If your base image already has it, you can skip this. - - name: Install .NET Runtime - run: | - # Example for Ubuntu. Adjust based on your .NET version (e.g., 8.0, 7.0) - # and if you need the SDK or just the runtime. - # This uses Microsoft's package repository for the latest versions. - wget https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb -O packages-microsoft-prod.deb - sudo dpkg -i packages-microsoft-prod.deb - rm packages-microsoft-prod.deb - sudo apt update - sudo apt install -y aspnetcore-runtime-9.0 - - - name: Install and Start as a Linux service + Expand-Archive -Path testhosts.zip -DestinationPath "C:\txnproc\transactionprocessing\testhosts" -Force + + - name: Install as a Windows service run: | - SERVICE_NAME="testhosts" - # The WorkingDirectory is crucial for .NET apps to find appsettings.json and other files - WORKING_DIRECTORY="/opt/txnproc/transactionprocessing/testhosts" - DLL_NAME="TestHosts.dll" # Your application's DLL - SERVICE_DESCRIPTION="Transaction Processing - Test Hosts" - - # Create a systemd service file - echo "[Unit]" | sudo tee /etc/systemd/system/${SERVICE_NAME}.service - echo "Description=${SERVICE_DESCRIPTION}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "After=network.target" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "[Service]" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - # IMPORTANT: Use 'dotnet' to run your DLL - echo "ExecStart=/usr/bin/dotnet ${WORKING_DIRECTORY}/${DLL_NAME}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "WorkingDirectory=${WORKING_DIRECTORY}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "Restart=always" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "User=youruser" # IMPORTANT: Change to a dedicated, less privileged user - echo "Group=yourgroup" # IMPORTANT: Change to a dedicated, less privileged group - echo "Environment=ASPNETCORE_ENVIRONMENT=Production" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service # Example - echo "" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "[Install]" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "WantedBy=multi-user.target" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - - # Reload systemd, enable, and start the service - sudo systemctl daemon-reload - sudo systemctl enable "$SERVICE_NAME" - sudo systemctl start "$SERVICE_NAME" - sudo systemctl status "$SERVICE_NAME" --no-pager # For debugging/verification + $serviceName = "Transaction Processing - Test Hosts" + $servicePath = "C:\txnproc\transactionprocessing\testhosts\testhosts.exe" + + New-Service -Name $serviceName -BinaryPathName $servicePath -Description $serviceName -DisplayName $serviceName -StartupType Automatic + Start-Service -Name $serviceName deployproduction: - runs-on: [productionserver, linux] - needs: [buildlinux, deploystaging] + runs-on: [productionserver, windows] + needs: [build, deploystaging] environment: production name: "Deploy to Production" @@ -149,70 +98,24 @@ jobs: uses: actions/download-artifact@v4.1.8 with: name: testhosts - path: /tmp/testhosts # Download to a temporary directory - - name: Remove existing service (if applicable) + - name: Remove existing Windows service run: | - SERVICE_NAME="testhosts" - if systemctl is-active --quiet "$SERVICE_NAME"; then - echo "Stopping existing service..." - sudo systemctl stop "$SERVICE_NAME" - fi - if systemctl is-enabled --quiet "$SERVICE_NAME"; then - echo "Disabling existing service..." - sudo systemctl disable "$SERVICE_NAME" - fi - if [ -f "/etc/systemd/system/${SERVICE_NAME}.service" ]; then - echo "Removing existing service unit file..." - sudo rm "/etc/systemd/system/${SERVICE_NAME}.service" - sudo systemctl daemon-reload - fi + $serviceName = "Transaction Processing - Test Hosts" + # Check if the service exists + if (Get-Service -Name $serviceName -ErrorAction SilentlyContinue) { + Stop-Service -Name $serviceName + sc.exe delete $serviceName + } - name: Unzip the files run: | - sudo mkdir -p /opt/txnproc/transactionprocessing/testhosts - sudo unzip -o /tmp/testhosts/testhosts.zip -d /opt/txnproc/transactionprocessing/testhosts - - # IMPORTANT: Add a step to ensure the .NET runtime is installed on the server - # This assumes it's not already there. If your base image already has it, you can skip this. - - name: Install .NET Runtime - run: | - # Example for Ubuntu. Adjust based on your .NET version (e.g., 8.0, 7.0) - # and if you need the SDK or just the runtime. - # This uses Microsoft's package repository for the latest versions. - wget https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb -O packages-microsoft-prod.deb - sudo dpkg -i packages-microsoft-prod.deb - rm packages-microsoft-prod.deb - sudo apt update - sudo apt install -y aspnetcore-runtime-9.0 - - - name: Install and Start as a Linux service + Expand-Archive -Path testhosts.zip -DestinationPath "C:\txnproc\transactionprocessing\testhosts" -Force + + - name: Install as a Windows service run: | - SERVICE_NAME="testhosts" - # The WorkingDirectory is crucial for .NET apps to find appsettings.json and other files - WORKING_DIRECTORY="/opt/txnproc/transactionprocessing/testhosts" - DLL_NAME="TestHosts.dll" # Your application's DLL - SERVICE_DESCRIPTION="Transaction Processing - Test Hosts" - - # Create a systemd service file - echo "[Unit]" | sudo tee /etc/systemd/system/${SERVICE_NAME}.service - echo "Description=${SERVICE_DESCRIPTION}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "After=network.target" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "[Service]" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - # IMPORTANT: Use 'dotnet' to run your DLL - echo "ExecStart=/usr/bin/dotnet ${WORKING_DIRECTORY}/${DLL_NAME}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "WorkingDirectory=${WORKING_DIRECTORY}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "Restart=always" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "User=youruser" # IMPORTANT: Change to a dedicated, less privileged user - echo "Group=yourgroup" # IMPORTANT: Change to a dedicated, less privileged group - echo "Environment=ASPNETCORE_ENVIRONMENT=Production" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service # Example - echo "" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "[Install]" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "WantedBy=multi-user.target" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - - # Reload systemd, enable, and start the service - sudo systemctl daemon-reload - sudo systemctl enable "$SERVICE_NAME" - sudo systemctl start "$SERVICE_NAME" - sudo systemctl status "$SERVICE_NAME" --no-pager # For debugging/verification + $serviceName = "Transaction Processing - Test Hosts" + $servicePath = "C:\txnproc\transactionprocessing\testhosts\testhosts.exe" + + New-Service -Name $serviceName -BinaryPathName $servicePath -Description $serviceName -DisplayName $serviceName -StartupType Automatic + Start-Service -Name $serviceName diff --git a/.github/workflows/pullrequest.yml b/.github/workflows/pullrequest.yml index ca8624c..d8c325b 100644 --- a/.github/workflows/pullrequest.yml +++ b/.github/workflows/pullrequest.yml @@ -15,11 +15,6 @@ jobs: steps: - uses: actions/checkout@v2.3.4 - - - name: Install NET 9 - uses: actions/setup-dotnet@v4.0.1 - with: - dotnet-version: '9.0.x' - name: Restore Nuget Packages run: dotnet restore TestHosts/TestHosts.sln --source ${{ secrets.PUBLICFEEDURL }} --source ${{ secrets.PRIVATEFEED_URL }} diff --git a/.github/workflows/pushtomaster.yml b/.github/workflows/pushtomaster.yml index f9144c2..edc3fc5 100644 --- a/.github/workflows/pushtomaster.yml +++ b/.github/workflows/pushtomaster.yml @@ -17,12 +17,7 @@ jobs: steps: - uses: actions/checkout@v2.3.4 with: - fetch-depth: 0 - - - name: Install NET 9 - uses: actions/setup-dotnet@v4.0.1 - with: - dotnet-version: '9.0.x' + fetch-depth: 0 - name: Restore Nuget Packages run: dotnet restore TestHosts/TestHosts.sln --source ${{ secrets.PUBLICFEEDURL }} --source ${{ secrets.PRIVATEFEED_URL }} diff --git a/TestHosts/TestHosts/Dockerfile b/TestHosts/TestHosts/Dockerfile index 1ff2687..05a25e6 100644 --- a/TestHosts/TestHosts/Dockerfile +++ b/TestHosts/TestHosts/Dockerfile @@ -1,7 +1,7 @@ FROM stuartferguson/txnprocbase:latest AS base WORKDIR /app -FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build +FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build WORKDIR /src COPY ["TestHosts/TestHosts.csproj", "TestHosts/"] COPY ["TestHosts/NuGet.Config", "TestHosts/"] diff --git a/TestHosts/TestHosts/Dockerfilewindows b/TestHosts/TestHosts/Dockerfilewindows index 4294739..7800dda 100644 --- a/TestHosts/TestHosts/Dockerfilewindows +++ b/TestHosts/TestHosts/Dockerfilewindows @@ -2,7 +2,7 @@ FROM stuartferguson/txnprocbasewindows AS base USER ContainerAdministrator WORKDIR /app -FROM mcr.microsoft.com/dotnet/sdk:9.0-windowsservercore-ltsc2022 AS build +FROM mcr.microsoft.com/dotnet/sdk:10.0-windowsservercore-ltsc2022 AS build WORKDIR /src COPY ["TestHosts/TestHosts.csproj", "TestHosts/"] COPY ["TestHosts/NuGet.Config", "TestHosts/"] diff --git a/TestHosts/TestHosts/Startup.cs b/TestHosts/TestHosts/Startup.cs index 321a0be..48eeb8d 100644 --- a/TestHosts/TestHosts/Startup.cs +++ b/TestHosts/TestHosts/Startup.cs @@ -1,55 +1,24 @@ -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; -using NLog.Extensions.Logging; -using Shared.Logger.TennantContext; using System; using System.Threading; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using Shared.Logger; -using TestHosts.Common; using TestHosts.Database.PataPawa; using TestHosts.Database.TestBank; namespace TestHosts { - using CoreWCF; - using CoreWCF.Configuration; - using CoreWCF.Description; - using CoreWCF.IdentityModel.Protocols.WSTrust; using Database.PataPawa; - using Database.TestBank; - using HealthChecks.UI.Client; - using Microsoft.AspNetCore.Diagnostics.HealthChecks; using Microsoft.EntityFrameworkCore; - using Microsoft.Extensions.Diagnostics.HealthChecks; - using Microsoft.Extensions.Logging; - using Microsoft.OpenApi.Models; - using Newtonsoft.Json; - using Newtonsoft.Json.Serialization; - using NLog; using Shared.EntityFramework; - using Shared.Extensions; - using Shared.General; - using Shared.Logger; - using Shared.Middleware; using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; - using System.Diagnostics.Metrics; - using System.DirectoryServices.Protocols; - using System.IO; using System.Linq; - using System.Runtime.InteropServices; - using System.ServiceModel; using System.Threading; using System.Threading.Tasks; - using TestHosts.SoapServices; - using ILogger = Microsoft.Extensions.Logging.ILogger; [ExcludeFromCodeCoverage] public class PendingPrePaymentProcessor : BackgroundService{ diff --git a/TestHosts/TestHosts/TestHosts.csproj b/TestHosts/TestHosts/TestHosts.csproj index 6c8f452..f10b56e 100644 --- a/TestHosts/TestHosts/TestHosts.csproj +++ b/TestHosts/TestHosts/TestHosts.csproj @@ -1,7 +1,7 @@  - net9.0 + net10.0 96de5658-e1fb-40f6-99ed-4203c8807474 Linux @@ -14,22 +14,22 @@ - - - - - + + + + + - + - + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive