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: |
latest="${{ vars.VERSION }}"
next_version=$(echo "$latest" | awk -F. -v OFS=. '{$NF += 1 ; print}')
echo "Next version: $next_version"
echo "next_version=$next_version" >> $GITHUB_ENV
echo "${{ vars.EXECUTABLE_NAME }}"
echo "${{ vars.RUNTIME }}"
echo "Variables used :"
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
uses: actions/setup-dotnet@v3
with:
@@ -30,7 +33,7 @@ jobs:
- name: Test with dotnet
run: dotnet test --logger trx --results-directory "TestResults-net8.0"
- 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
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
- 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
with:
args: zip -qq -r ${{ github.event.repository.name }}.zip publish/
@@ -68,7 +71,7 @@ jobs:
- name: upload latest executable version with version number
run: |
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"
@@ -80,7 +83,7 @@ jobs:
- name: upload latest executable version
run: |
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
+260 -187
View File
@@ -1,188 +1,261 @@
using System.Configuration;
using System.Configuration.Internal;
//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
// cancelled as the program would crash , to be investigated
// V1.2 displaying starting complete 2025/10/15
static class Program
{
private static readonly Dictionary<string,string> ServicesList = ConfigurationManager.AppSettings.AllKeys.ToDictionary(key => key, key => ConfigurationManager.AppSettings[key]);
public static bool KeycloakHidden = true;
public static bool PostgreSqlHidden = true;
public static readonly string version = "V1.2";
[STAThread]
private static void StartService(string serviceName, int timeoutMilliseconds)
{
ServiceController service = new ServiceController(serviceName);
try
{
TimeSpan timeout = TimeSpan.FromMilliseconds(timeoutMilliseconds);
service.Start();
service.WaitForStatus(ServiceControllerStatus.Running, timeout);
}
catch
{
// ...
}
}
private static void StopService(string serviceName, int timeoutMilliseconds)
{
ServiceController service = new ServiceController(serviceName);
try
{
TimeSpan timeout = TimeSpan.FromMilliseconds(timeoutMilliseconds);
service.Stop();
service.WaitForStatus(ServiceControllerStatus.Stopped, timeout);
}
catch
{
// ...
}
}
public static void StartServices()
{
if(!Form1.KeycloakCheckBox.Checked)
{
Console.WriteLine("Keycloak unchecked");
ServicesList.Remove("_keycloak");
Form1.KeycloakCheckBox.Visible = false;
}
foreach (KeyValuePair<string,string> Service in ServicesList)
{
//Console.WriteLine("checked: "+Form1.KeycloakCheckBox.Checked);
//write the service name in the log
Console.WriteLine("Starting: "+Service.Key);
//start the service
StartService(Service.Key, 1000);
//update the text box
Form1.TextDisplay.Text = "Starting: "+Service.Key;
Form1.TextDisplay.Update();
//wait 1 second before
Thread.Sleep(TimeSpan.FromSeconds(1));
//displaying end of operation
Form1.TextDisplay.Text = "Starting complete ! ";
Form1.TextDisplay.Update();
}
}
public static void ShutdownServices(bool keycloakRestartRequired)
{
if(!Form1.KeycloakCheckBox.Checked)
{
Console.WriteLine("Keycloak unchecked");
ServicesList.Remove("_keycloak");
Form1.KeycloakCheckBox.Visible = false;
}
foreach (KeyValuePair<string,string> Service in ServicesList.Reverse())
{
//write the service name in the log
Console.WriteLine("Stopping: "+Service.Key);
//start the service
StopService(Service.Key, 1000);
//update the text box
Form1.TextDisplay.Text = "Stopping: "+Service.Key;
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)
{
Console.WriteLine("Keycloak unchecked");
ServicesList.Remove("_keycloak");
Form1.KeycloakCheckBox.Visible = false;
}
//stop section
foreach (KeyValuePair<string,string> Service in ServicesList.Reverse())
{
//write the service name in the log
Console.WriteLine("Stopping: "+Service.Key);
//stop the service
StopService(Service.Key, 1000);
//update the text box
Form1.TextDisplay.Text = "Stopping: "+Service.Key;
Form1.TextDisplay.Update();
//wait 1 second before
Thread.Sleep(TimeSpan.FromSeconds(1));
//displaying end of operation
Form1.TextDisplay.Text = "Stopping complete ! ";
Form1.TextDisplay.Update();
}
Form1.TextDisplay.Text = "Stopping Complete, waiting... ";
Form1.TextDisplay.Update();
//wait 3 second before
Thread.Sleep(TimeSpan.FromSeconds(3));
//start section
foreach (KeyValuePair<string,string> Service in ServicesList)
{
//write the service name in the log
Console.WriteLine("Starting: "+Service.Key);
//start the service
StartService(Service.Key, 1000);
//update the text box
Form1.TextDisplay.Text = "Starting: "+Service.Key;
Form1.TextDisplay.Update();
//wait 1 second before
Thread.Sleep(TimeSpan.FromSeconds(1));
//displaying end of operation
Form1.TextDisplay.Text = "Starting complete ! ";
Form1.TextDisplay.Update();
}
}
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());
}
using System.Configuration;
using System.Configuration.Internal;
using System.Diagnostics;
//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
// cancelled as the program would crash , to be investigated
// V1.2 displaying starting complete 2025/10/15
// V1.3 detect stuck processes and kill them
static class Program
{
private static readonly Dictionary<string,string> ServicesList = ConfigurationManager.AppSettings.AllKeys.ToDictionary(key => key, key => ConfigurationManager.AppSettings[key]);
public static bool KeycloakHidden = true;
public static bool PostgreSqlHidden = true;
public static readonly string version = "V1.3";
[STAThread]
private static void StartService(string serviceName, int timeoutMilliseconds)
{
ServiceController service = new ServiceController(serviceName);
try
{
TimeSpan timeout = TimeSpan.FromMilliseconds(timeoutMilliseconds);
service.Start();
service.WaitForStatus(ServiceControllerStatus.Running, timeout);
}
catch
{
// ...
}
}
private static void StopService(string serviceName, int timeoutMilliseconds)
{
ServiceController service = new ServiceController(serviceName);
try
{
TimeSpan timeout = TimeSpan.FromMilliseconds(timeoutMilliseconds);
service.Stop();
service.WaitForStatus(ServiceControllerStatus.Stopped, timeout);
}
catch
{
// ...
}
}
public static void StartServices()
{
if(!Form1.KeycloakCheckBox.Checked)
{
Console.WriteLine("Keycloak unchecked");
ServicesList.Remove("_keycloak");
Form1.KeycloakCheckBox.Visible = false;
}
foreach (KeyValuePair<string,string> Service in ServicesList)
{
//Console.WriteLine("checked: "+Form1.KeycloakCheckBox.Checked);
//write the service name in the log
Console.WriteLine("Starting: "+Service.Key);
//start the service
StartService(Service.Key, 1000);
//update the text box
Form1.TextDisplay.Text = "Starting: "+Service.Key;
Form1.TextDisplay.Update();
//wait 1 second before
Thread.Sleep(TimeSpan.FromSeconds(1));
//displaying end of operation
Form1.TextDisplay.Text = "Starting complete ! ";
Form1.TextDisplay.Update();
}
}
public static void ShutdownServices(bool keycloakRestartRequired)
{
//DisplayNetstat();
Thread.Sleep(TimeSpan.FromSeconds(3));
if(!Form1.KeycloakCheckBox.Checked)
{
Console.WriteLine("Keycloak unchecked");
ServicesList.Remove("_keycloak");
Form1.KeycloakCheckBox.Visible = false;
}
foreach (KeyValuePair<string,string> Service in ServicesList.Reverse())
{
//write the service name in the log
Console.WriteLine("Stopping: "+Service.Key);
//start the service
StopService(Service.Key, 1000);
//update the text box
Form1.TextDisplay.Text = "Stopping: "+Service.Key;
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)
{
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 = "Stopping complete ! ";
Form1.TextDisplay.Update();
}
}
public static void RestartServices(bool keycloakRestartRequired)
{
if(!Form1.KeycloakCheckBox.Checked)
{
Console.WriteLine("Keycloak unchecked");
ServicesList.Remove("_keycloak");
Form1.KeycloakCheckBox.Visible = false;
}
//stop section
foreach (KeyValuePair<string,string> Service in ServicesList.Reverse())
{
//write the service name in the log
Console.WriteLine("Stopping: "+Service.Key);
//stop the service
StopService(Service.Key, 1000);
//update the text box
Form1.TextDisplay.Text = "Stopping: "+Service.Key;
Form1.TextDisplay.Update();
//wait 1 second before
Thread.Sleep(TimeSpan.FromSeconds(1));
//displaying end of operation
Form1.TextDisplay.Text = "Stopping complete ! ";
Form1.TextDisplay.Update();
}
Form1.TextDisplay.Text = "Stopping Complete, waiting... ";
Form1.TextDisplay.Update();
//wait 3 second before
Thread.Sleep(TimeSpan.FromSeconds(3));
//start section
foreach (KeyValuePair<string,string> Service in ServicesList)
{
//write the service name in the log
Console.WriteLine("Starting: "+Service.Key);
//start the service
StartService(Service.Key, 1000);
//update the text box
Form1.TextDisplay.Text = "Starting: "+Service.Key;
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)
{
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>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
<ApplicationIcon>webclip_webclip-Photoroom.ico</ApplicationIcon>
<EnableWindowsTargeting>true</EnableWindowsTargeting>
<ApplicationIcon>prometheus.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
@@ -14,4 +15,4 @@
<PackageReference Include="System.ServiceProcess.ServiceController" Version="10.0.0-preview.5.25277.114" />
</ItemGroup>
</Project>
</Project>
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.