Compare commits

..
6 Commits
Author SHA1 Message Date
pi-ux-ce 873438b4bf loop through stuck process and kill them
Gitea Actions Demo / Explore-Gitea-Actions (8.0.x) (push) Successful in 2m7s
2025-11-13 14:53:17 +00:00
Pierre Geeraert 21b7f862f9 add CI/cd file from template
Gitea Actions Demo / Explore-Gitea-Actions (8.0.x) (push) Successful in 2m1s
2025-11-06 15:36:43 +00:00
Pierre Geeraert 37fb726d63 fix runtime
Gitea Actions Demo / Explore-Gitea-Actions (8.0.x) (push) Failing after 1m39s
2025-11-06 15:08:02 +00:00
Pierre Geeraert 3205ec340b set the EnableWindowsTargeting property to true
Gitea Actions Demo / Explore-Gitea-Actions (8.0.x) (push) Failing after 1m31s
2025-11-06 15:02:59 +00:00
Pierre Geeraert 23b0d4f806 remove old files
Gitea Actions Demo / Explore-Gitea-Actions (8.0.x) (push) Failing after 1m27s
2025-11-06 14:34:25 +00:00
Pierre Geeraert 0b879bdd6f remove zone identifier file 2025-11-06 14:32:12 +00:00
6 changed files with 273 additions and 213 deletions
+10 -7
View File
@@ -17,10 +17,13 @@ jobs:
run: | run: |
latest="${{ vars.VERSION }}" latest="${{ vars.VERSION }}"
next_version=$(echo "$latest" | awk -F. -v OFS=. '{$NF += 1 ; print}') next_version=$(echo "$latest" | awk -F. -v OFS=. '{$NF += 1 ; print}')
echo "Next version: $next_version"
echo "next_version=$next_version" >> $GITHUB_ENV echo "next_version=$next_version" >> $GITHUB_ENV
echo "${{ vars.EXECUTABLE_NAME }}" echo "Variables used :"
echo "${{ vars.RUNTIME }}" echo "------------------------------------------------"
echo "Next version: $next_version"
echo "EXECUTABLE_NAME: ${{ vars.EXECUTABLE_NAME }}"
echo "RUNTIME: ${{ vars.RUNTIME }}"
echo "TARGET_FRAMEWORK: ${{ vars.TARGET_FRAMEWORK }}"
- name: Setup dotnet - name: Setup dotnet
uses: actions/setup-dotnet@v3 uses: actions/setup-dotnet@v3
with: with:
@@ -30,7 +33,7 @@ jobs:
- name: Test with dotnet - name: Test with dotnet
run: dotnet test --logger trx --results-directory "TestResults-net8.0" run: dotnet test --logger trx --results-directory "TestResults-net8.0"
- name: Build the package - name: Build the package
run: dotnet build -p:Version=$next_version,FileVersion=$next_version,AssemblyVersion=$next_version,InformationalVersion=$next_version run: dotnet build
- name: Publish the package - name: Publish the package
run: dotnet publish -p:PublishSingleFile=true,AssemblyName=${{ vars.EXECUTABLE_NAME }},Version=$next_version,FileVersion=$next_version,AssemblyVersion=$next_version,InformationalVersion=$next_version --self-contained false --runtime ${{ vars.RUNTIME }} run: dotnet publish -p:PublishSingleFile=true,AssemblyName=${{ vars.EXECUTABLE_NAME }},Version=$next_version,FileVersion=$next_version,AssemblyVersion=$next_version,InformationalVersion=$next_version --self-contained false --runtime ${{ vars.RUNTIME }}
@@ -39,7 +42,7 @@ jobs:
find /workspace find /workspace
- name: copy the release before compression - name: copy the release before compression
run: cp -r /workspace/pi-ux-ce/${{ github.event.repository.name }}/bin/Release/net8.0/${{ vars.RUNTIME }}/publish/ . run: cp -r /workspace/pi-ux-ce/${{ github.event.repository.name }}/bin/Release/${{ vars.TARGET_FRAMEWORK }}/${{ vars.RUNTIME }}/publish/ .
- uses: montudor/action-zip@v1 - uses: montudor/action-zip@v1
with: with:
args: zip -qq -r ${{ github.event.repository.name }}.zip publish/ args: zip -qq -r ${{ github.event.repository.name }}.zip publish/
@@ -68,7 +71,7 @@ jobs:
- name: upload latest executable version with version number - name: upload latest executable version with version number
run: | run: |
curl --user ${{ secrets.USERNAME_GITEA }}:${{ secrets.PASSWORD_GITEA }} \ curl --user ${{ secrets.USERNAME_GITEA }}:${{ secrets.PASSWORD_GITEA }} \
--upload-file /workspace/pi-ux-ce/${{ github.event.repository.name }}/bin/Release/net8.0/${{ vars.RUNTIME }}/publish/${{ vars.EXECUTABLE_NAME }}.exe \ --upload-file /workspace/pi-ux-ce/${{ github.event.repository.name }}/bin/Release/${{ vars.TARGET_FRAMEWORK }}/${{ vars.RUNTIME }}/publish/${{ vars.EXECUTABLE_NAME }}.exe \
"https://gitea.tryton.geeraert.eu/api/packages/pi-ux-ce/generic/${{ github.event.repository.name }}/$next_version/${{ github.event.repository.name }}.exe" "https://gitea.tryton.geeraert.eu/api/packages/pi-ux-ce/generic/${{ github.event.repository.name }}/$next_version/${{ github.event.repository.name }}.exe"
@@ -80,7 +83,7 @@ jobs:
- name: upload latest executable version - name: upload latest executable version
run: | run: |
curl --user ${{ secrets.USERNAME_GITEA }}:${{ secrets.PASSWORD_GITEA }} \ curl --user ${{ secrets.USERNAME_GITEA }}:${{ secrets.PASSWORD_GITEA }} \
--upload-file /workspace/pi-ux-ce/${{ github.event.repository.name }}/bin/Release/net8.0/${{ vars.RUNTIME }}/publish/${{ vars.EXECUTABLE_NAME }}.exe \ --upload-file /workspace/pi-ux-ce/${{ github.event.repository.name }}/bin/Release/${{ vars.TARGET_FRAMEWORK }}/${{ vars.RUNTIME }}/publish/${{ vars.EXECUTABLE_NAME }}.exe \
https://gitea.tryton.geeraert.eu/api/packages/pi-ux-ce/generic/${{ github.event.repository.name }}/latest/${{ vars.EXECUTABLE_NAME }}.exe https://gitea.tryton.geeraert.eu/api/packages/pi-ux-ce/generic/${{ github.event.repository.name }}/latest/${{ vars.EXECUTABLE_NAME }}.exe
+260 -187
View File
@@ -1,188 +1,261 @@
using System.Configuration; using System.Configuration;
using System.Configuration.Internal; using System.Configuration.Internal;
//using Microsoft.Extensions.Configuration; using System.Diagnostics;
namespace PrometheusServiceManager;
using System.ServiceProcess; //using Microsoft.Extensions.Configuration;
namespace PrometheusServiceManager;
using System.ServiceProcess;
// versions
// V1 main release to customers system
// V1.1 adding the Administrator option at the start // versions
// cancelled as the program would crash , to be investigated // V1 main release to customers system
// V1.2 displaying starting complete 2025/10/15 // V1.1 adding the Administrator option at the start
static class Program // cancelled as the program would crash , to be investigated
{ // V1.2 displaying starting complete 2025/10/15
private static readonly Dictionary<string,string> ServicesList = ConfigurationManager.AppSettings.AllKeys.ToDictionary(key => key, key => ConfigurationManager.AppSettings[key]); // V1.3 detect stuck processes and kill them
public static bool KeycloakHidden = true; static class Program
public static bool PostgreSqlHidden = true; {
private static readonly Dictionary<string,string> ServicesList = ConfigurationManager.AppSettings.AllKeys.ToDictionary(key => key, key => ConfigurationManager.AppSettings[key]);
public static readonly string version = "V1.2"; public static bool KeycloakHidden = true;
public static bool PostgreSqlHidden = true;
[STAThread]
public static readonly string version = "V1.3";
private static void StartService(string serviceName, int timeoutMilliseconds)
{ [STAThread]
ServiceController service = new ServiceController(serviceName);
try private static void StartService(string serviceName, int timeoutMilliseconds)
{ {
TimeSpan timeout = TimeSpan.FromMilliseconds(timeoutMilliseconds); ServiceController service = new ServiceController(serviceName);
try
service.Start(); {
service.WaitForStatus(ServiceControllerStatus.Running, timeout); TimeSpan timeout = TimeSpan.FromMilliseconds(timeoutMilliseconds);
}
catch service.Start();
{ service.WaitForStatus(ServiceControllerStatus.Running, timeout);
// ... }
} catch
} {
// ...
private static void StopService(string serviceName, int timeoutMilliseconds) }
{ }
ServiceController service = new ServiceController(serviceName);
try private static void StopService(string serviceName, int timeoutMilliseconds)
{ {
TimeSpan timeout = TimeSpan.FromMilliseconds(timeoutMilliseconds); ServiceController service = new ServiceController(serviceName);
try
service.Stop(); {
service.WaitForStatus(ServiceControllerStatus.Stopped, timeout); TimeSpan timeout = TimeSpan.FromMilliseconds(timeoutMilliseconds);
}
catch service.Stop();
{ service.WaitForStatus(ServiceControllerStatus.Stopped, timeout);
// ... }
} catch
} {
public static void StartServices() // ...
{ }
if(!Form1.KeycloakCheckBox.Checked) }
{ public static void StartServices()
Console.WriteLine("Keycloak unchecked"); {
ServicesList.Remove("_keycloak"); if(!Form1.KeycloakCheckBox.Checked)
Form1.KeycloakCheckBox.Visible = false; {
Console.WriteLine("Keycloak unchecked");
} ServicesList.Remove("_keycloak");
foreach (KeyValuePair<string,string> Service in ServicesList) Form1.KeycloakCheckBox.Visible = false;
{
}
//Console.WriteLine("checked: "+Form1.KeycloakCheckBox.Checked); foreach (KeyValuePair<string,string> Service in ServicesList)
//write the service name in the log {
Console.WriteLine("Starting: "+Service.Key);
//start the service //Console.WriteLine("checked: "+Form1.KeycloakCheckBox.Checked);
StartService(Service.Key, 1000); //write the service name in the log
//update the text box Console.WriteLine("Starting: "+Service.Key);
Form1.TextDisplay.Text = "Starting: "+Service.Key; //start the service
Form1.TextDisplay.Update(); StartService(Service.Key, 1000);
//wait 1 second before //update the text box
Thread.Sleep(TimeSpan.FromSeconds(1)); Form1.TextDisplay.Text = "Starting: "+Service.Key;
Form1.TextDisplay.Update();
//displaying end of operation //wait 1 second before
Form1.TextDisplay.Text = "Starting complete ! "; Thread.Sleep(TimeSpan.FromSeconds(1));
Form1.TextDisplay.Update();
//displaying end of operation
} Form1.TextDisplay.Text = "Starting complete ! ";
Form1.TextDisplay.Update();
}
}
public static void ShutdownServices(bool keycloakRestartRequired) }
{
if(!Form1.KeycloakCheckBox.Checked)
{ public static void ShutdownServices(bool keycloakRestartRequired)
Console.WriteLine("Keycloak unchecked"); {
ServicesList.Remove("_keycloak"); //DisplayNetstat();
Form1.KeycloakCheckBox.Visible = false; Thread.Sleep(TimeSpan.FromSeconds(3));
} if(!Form1.KeycloakCheckBox.Checked)
foreach (KeyValuePair<string,string> Service in ServicesList.Reverse()) {
{ Console.WriteLine("Keycloak unchecked");
//write the service name in the log ServicesList.Remove("_keycloak");
Console.WriteLine("Stopping: "+Service.Key); Form1.KeycloakCheckBox.Visible = false;
//start the service }
StopService(Service.Key, 1000); foreach (KeyValuePair<string,string> Service in ServicesList.Reverse())
//update the text box {
Form1.TextDisplay.Text = "Stopping: "+Service.Key; //write the service name in the log
Form1.TextDisplay.Update(); Console.WriteLine("Stopping: "+Service.Key);
//wait 1 second before //start the service
Thread.Sleep(TimeSpan.FromSeconds(1)); StopService(Service.Key, 1000);
//update the text box
//displaying end of operation Form1.TextDisplay.Text = "Stopping: "+Service.Key;
Form1.TextDisplay.Text = "Stopping complete ! "; Form1.TextDisplay.Update();
Form1.TextDisplay.Update(); //wait 1 second before
Thread.Sleep(TimeSpan.FromSeconds(1));
} //check if there is a process still active
Process[] localByName = Process.GetProcessesByName(Service.Value);
} if (localByName.Length > 0)
public static void RestartServices(bool keycloakRestartRequired) {
{ Form1.TextDisplay.Text = "there is a process running ";
if(!Form1.KeycloakCheckBox.Checked) Form1.TextDisplay.Update();
{ Thread.Sleep(TimeSpan.FromSeconds(1));
Console.WriteLine("Keycloak unchecked");
ServicesList.Remove("_keycloak"); //loop through every process if multiples
Form1.KeycloakCheckBox.Visible = false; foreach (Process process in localByName)
{
} process.Kill();
//stop section }
foreach (KeyValuePair<string,string> Service in ServicesList.Reverse())
{ Form1.TextDisplay.Text = "kill done ";
//write the service name in the log Form1.TextDisplay.Update();
Console.WriteLine("Stopping: "+Service.Key);
//stop the service }
StopService(Service.Key, 1000);
//update the text box //displaying end of operation
Form1.TextDisplay.Text = "Stopping: "+Service.Key; Form1.TextDisplay.Text = "Stopping complete ! ";
Form1.TextDisplay.Update(); Form1.TextDisplay.Update();
//wait 1 second before
Thread.Sleep(TimeSpan.FromSeconds(1));
}
//displaying end of operation
Form1.TextDisplay.Text = "Stopping complete ! "; }
Form1.TextDisplay.Update(); public static void RestartServices(bool keycloakRestartRequired)
{
if(!Form1.KeycloakCheckBox.Checked)
} {
Form1.TextDisplay.Text = "Stopping Complete, waiting... "; Console.WriteLine("Keycloak unchecked");
Form1.TextDisplay.Update(); ServicesList.Remove("_keycloak");
//wait 3 second before Form1.KeycloakCheckBox.Visible = false;
Thread.Sleep(TimeSpan.FromSeconds(3));
}
//start section //stop section
foreach (KeyValuePair<string,string> Service in ServicesList) foreach (KeyValuePair<string,string> Service in ServicesList.Reverse())
{ {
//write the service name in the log //write the service name in the log
Console.WriteLine("Starting: "+Service.Key); Console.WriteLine("Stopping: "+Service.Key);
//start the service //stop the service
StartService(Service.Key, 1000); StopService(Service.Key, 1000);
//update the text box //update the text box
Form1.TextDisplay.Text = "Starting: "+Service.Key; Form1.TextDisplay.Text = "Stopping: "+Service.Key;
Form1.TextDisplay.Update(); Form1.TextDisplay.Update();
//wait 1 second before //wait 1 second before
Thread.Sleep(TimeSpan.FromSeconds(1)); Thread.Sleep(TimeSpan.FromSeconds(1));
//displaying end of operation //displaying end of operation
Form1.TextDisplay.Text = "Starting complete ! "; Form1.TextDisplay.Text = "Stopping complete ! ";
Form1.TextDisplay.Update(); Form1.TextDisplay.Update();
}
} }
static void Main() Form1.TextDisplay.Text = "Stopping Complete, waiting... ";
{ Form1.TextDisplay.Update();
//wait 3 second before
Thread.Sleep(TimeSpan.FromSeconds(3));
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration. //start section
foreach (KeyValuePair<string,string> Service in ServicesList)
if (ServicesList.ContainsKey("_keycloak")) {
{ //write the service name in the log
Program.KeycloakHidden = false; Console.WriteLine("Starting: "+Service.Key);
Console.WriteLine("keycloak is there"); //start the service
} StartService(Service.Key, 1000);
if (ServicesList.ContainsKey("_postgresql")) //update the text box
{ Form1.TextDisplay.Text = "Starting: "+Service.Key;
Program.PostgreSqlHidden = false; Form1.TextDisplay.Update();
Console.WriteLine("postgresql is there"); //wait 1 second before
} Thread.Sleep(TimeSpan.FromSeconds(1));
ApplicationConfiguration.Initialize();
Application.Run(new Form1()); //check if there is a process still active
Process[] localByName = Process.GetProcessesByName(Service.Value);
if (localByName.Length > 0)
} {
Form1.TextDisplay.Text = "there is a process running ";
Form1.TextDisplay.Update();
Thread.Sleep(TimeSpan.FromSeconds(1));
//loop through every process if multiples
foreach (Process process in localByName)
{
process.Kill();
}
Form1.TextDisplay.Text = "kill done ";
Form1.TextDisplay.Update();
}
//displaying end of operation
Form1.TextDisplay.Text = "Starting complete ! ";
Form1.TextDisplay.Update();
}
}
public static void DisplayNetstat()
{
try
{
Process[] localByName = Process.GetProcessesByName("TurnaroundService.api");
if (localByName.Length > 0)
{
Form1.TextDisplay.Text = "there is a service running ";
Form1.TextDisplay.Update();
Thread.Sleep(TimeSpan.FromSeconds(2));
localByName[0].Kill();
Form1.TextDisplay.Text = "kill done ";
Form1.TextDisplay.Update();
}
}
catch (Exception e)
{
Form1.TextDisplay.Text = "Kill failed ! ";
Form1.TextDisplay.Update();
Console.WriteLine(e);
throw;
}
}
static void Main()
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
if (ServicesList.ContainsKey("_keycloak"))
{
Program.KeycloakHidden = false;
Console.WriteLine("keycloak is there");
}
if (ServicesList.ContainsKey("_postgresql"))
{
Program.PostgreSqlHidden = false;
Console.WriteLine("postgresql is there");
}
ApplicationConfiguration.Initialize();
Application.Run(new Form1());
}
} }
-17
View File
@@ -1,17 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<ApplicationIcon>icon.ico</ApplicationIcon>
<Authors>Pierre Geeraert</Authors>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<!-- Versioning properties -->
<!-- Company information -->
</PropertyGroup>
</Project>
+3 -2
View File
@@ -6,7 +6,8 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms> <UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<ApplicationIcon>webclip_webclip-Photoroom.ico</ApplicationIcon> <EnableWindowsTargeting>true</EnableWindowsTargeting>
<ApplicationIcon>prometheus.ico</ApplicationIcon>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@@ -14,4 +15,4 @@
<PackageReference Include="System.ServiceProcess.ServiceController" Version="10.0.0-preview.5.25277.114" /> <PackageReference Include="System.ServiceProcess.ServiceController" Version="10.0.0-preview.5.25277.114" />
</ItemGroup> </ItemGroup>
</Project> </Project>
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.