add the code
Gitea Actions Demo / Explore-Gitea-Actions (8.0.x) (push) Failing after 1m20s

This commit is contained in:
Pierre Geeraert
2025-11-06 14:31:51 +00:00
parent b2b7b32dfc
commit 6b9ca34110
8 changed files with 22106 additions and 4 deletions
+181 -4
View File
@@ -1,11 +1,188 @@
namespace dotnet_build;
using System.Configuration;
using System.Configuration.Internal;
//using Microsoft.Extensions.Configuration;
namespace PrometheusServiceManager;
using System.ServiceProcess;
class Program
// 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)
{
static void Main(string[] args)
ServiceController service = new ServiceController(serviceName);
try
{
Console.WriteLine("hello world");
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());
}
}