Skip to content

Commit 7a05425

Browse files
[Add] ascii-art splashscreen and log it; fixes #754
[Add] explicit kestrel configuration to appsettings
1 parent 43b6a64 commit 7a05425

File tree

7 files changed

+264
-21
lines changed

7 files changed

+264
-21
lines changed

COMETwebapp/COMETwebapp.csproj

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFramework>net9.0</TargetFramework>
5-
<Version>6.2.0</Version>
5+
<Version>6.2.1</Version>
66
<Title>CDP4-COMET WEB</Title>
77
<Description>A web application that implements ECSS-E-TM-10-25</Description>
88
<Company>Starion Group S.A.</Company>
@@ -17,6 +17,14 @@
1717
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1818
</PropertyGroup>
1919

20+
<ItemGroup>
21+
<None Remove="Resources\ascii-art.txt" />
22+
</ItemGroup>
23+
24+
<ItemGroup>
25+
<EmbeddedResource Include="Resources\ascii-art.txt" />
26+
</ItemGroup>
27+
2028
<ItemGroup>
2129
<PackageReference Include="AntDesign" Version="1.2.0" />
2230
<PackageReference Include="BlazorStrap" Version="5.2.103.250102" />

COMETwebapp/Extensions/ServiceCollectionExtensions.cs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
namespace COMETwebapp.Extensions
2626
{
2727
using COMETwebapp.Model.Viewer;
28+
using COMETwebapp.Resources;
2829
using COMETwebapp.Services.Interoperability;
2930
using COMETwebapp.Services.ShowHideDeprecatedThingsService;
3031
using COMETwebapp.Services.SubscriptionService;
@@ -34,34 +35,34 @@ namespace COMETwebapp.Extensions
3435
using COMETwebapp.ViewModels.Components.EngineeringModel;
3536
using COMETwebapp.ViewModels.Components.EngineeringModel.CommonFileStore;
3637
using COMETwebapp.ViewModels.Components.EngineeringModel.DomainFileStore;
38+
using COMETwebapp.ViewModels.Components.EngineeringModel.FileStore;
39+
using COMETwebapp.ViewModels.Components.EngineeringModel.FileStore.FileHandler;
40+
using COMETwebapp.ViewModels.Components.EngineeringModel.FileStore.FileRevisionHandler;
41+
using COMETwebapp.ViewModels.Components.EngineeringModel.FileStore.FolderHandler;
3742
using COMETwebapp.ViewModels.Components.EngineeringModel.Options;
3843
using COMETwebapp.ViewModels.Components.EngineeringModel.Publications;
39-
using COMETwebapp.ViewModels.Components.SiteDirectory.DomainsOfExpertise;
4044
using COMETwebapp.ViewModels.Components.ModelDashboard;
4145
using COMETwebapp.ViewModels.Components.ModelDashboard.ParameterValues;
4246
using COMETwebapp.ViewModels.Components.ModelEditor;
47+
using COMETwebapp.ViewModels.Components.ModelEditor.CopySettings;
4348
using COMETwebapp.ViewModels.Components.ParameterEditor;
49+
using COMETwebapp.ViewModels.Components.ParameterEditor.BatchParameterEditor;
50+
using COMETwebapp.ViewModels.Components.ReferenceData;
4451
using COMETwebapp.ViewModels.Components.ReferenceData.Categories;
4552
using COMETwebapp.ViewModels.Components.ReferenceData.MeasurementScales;
4653
using COMETwebapp.ViewModels.Components.ReferenceData.MeasurementUnits;
4754
using COMETwebapp.ViewModels.Components.ReferenceData.ParameterTypes;
55+
using COMETwebapp.ViewModels.Components.SiteDirectory;
56+
using COMETwebapp.ViewModels.Components.SiteDirectory.DomainsOfExpertise;
4857
using COMETwebapp.ViewModels.Components.SiteDirectory.EngineeringModels;
4958
using COMETwebapp.ViewModels.Components.SiteDirectory.Organizations;
5059
using COMETwebapp.ViewModels.Components.SiteDirectory.Roles;
60+
using COMETwebapp.ViewModels.Components.SiteDirectory.UserManagement;
5161
using COMETwebapp.ViewModels.Components.SubscriptionDashboard;
5262
using COMETwebapp.ViewModels.Components.SystemRepresentation;
53-
using COMETwebapp.ViewModels.Components.SiteDirectory.UserManagement;
5463
using COMETwebapp.ViewModels.Components.Viewer;
55-
using COMETwebapp.ViewModels.Shared.TopMenuEntry;
56-
using COMETwebapp.ViewModels.Components.EngineeringModel.FileStore;
57-
using COMETwebapp.ViewModels.Components.EngineeringModel.FileStore.FileHandler;
58-
using COMETwebapp.ViewModels.Components.EngineeringModel.FileStore.FileRevisionHandler;
59-
using COMETwebapp.ViewModels.Components.EngineeringModel.FileStore.FolderHandler;
60-
using COMETwebapp.ViewModels.Components.ModelEditor.CopySettings;
61-
using COMETwebapp.ViewModels.Components.ParameterEditor.BatchParameterEditor;
62-
using COMETwebapp.ViewModels.Components.ReferenceData;
6364
using COMETwebapp.ViewModels.Pages;
64-
using COMETwebapp.ViewModels.Components.SiteDirectory;
65+
using COMETwebapp.ViewModels.Shared.TopMenuEntry;
6566

6667
/// <summary>
6768
/// Extension class for the <see cref="IServiceCollection" />
@@ -74,6 +75,7 @@ public static class ServiceCollectionExtensions
7475
/// <param name="serviceCollection">The <see cref="IServiceCollection" /></param>
7576
public static void RegisterServices(this IServiceCollection serviceCollection)
7677
{
78+
serviceCollection.AddSingleton<IResourceLoader, ResourceLoader>();
7779
serviceCollection.AddScoped<ISubscriptionService, SubscriptionService>();
7880
serviceCollection.AddScoped<IShowHideDeprecatedThingsService, ShowHideDeprecatedThingsService>();
7981
serviceCollection.AddScoped<ISceneSettings, SceneSettings>();

COMETwebapp/Program.cs

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,19 @@
2424

2525
namespace COMETwebapp
2626
{
27+
using System;
2728
using System.Diagnostics.CodeAnalysis;
2829
using System.Reflection;
2930

3031
using COMET.Web.Common.Extensions;
31-
32+
3233
using COMETwebapp.Extensions;
3334
using COMETwebapp.Model;
35+
using COMETwebapp.Resources;
3436
using COMETwebapp.Shared;
3537
using COMETwebapp.Shared.SideBarEntry;
3638
using COMETwebapp.Shared.TopMenuEntry;
37-
39+
3840
using Serilog;
3941

4042
/// <summary>
@@ -46,8 +48,10 @@ public class Program
4648
/// <summary>
4749
/// Point of entry of the application
4850
/// </summary>
49-
public static async Task Main(string[] args)
51+
public static async Task<int> Main(string[] args)
5052
{
53+
Console.Title = "CDP4-COMET WEB";
54+
5155
var builder = WebApplication.CreateBuilder(args);
5256

5357
builder.Services.AddRazorPages();
@@ -73,13 +77,38 @@ public static async Task Main(string[] args)
7377
});
7478

7579
var app = builder.Build();
76-
app.UseStaticFiles();
77-
app.UseRouting();
78-
app.MapBlazorHub();
79-
app.MapFallbackToPage("/_Host");
8080

81-
await app.Services.InitializeCdp4CometCommonServices();
82-
await app.RunAsync();
81+
var logger = app.Services.GetService<ILogger<Program>>();
82+
83+
try
84+
{
85+
var resourceLoader = app.Services.GetService<IResourceLoader>();
86+
87+
logger.LogInformation(resourceLoader.QueryLogo());
88+
89+
logger.LogInformation("################################################################");
90+
91+
logger.LogInformation("Starting CDP4-COMET WEB v{version}", resourceLoader.QueryVersion());
92+
93+
app.UseStaticFiles();
94+
app.UseRouting();
95+
app.MapBlazorHub();
96+
app.MapFallbackToPage("/_Host");
97+
98+
await app.Services.InitializeCdp4CometCommonServices();
99+
100+
logger.LogInformation("CDP4-COMET WEB is running and accepting connections");
101+
102+
await app.RunAsync();
103+
104+
logger.LogInformation("Terminated CDP4-COMET WEB cleanly");
105+
return 0;
106+
}
107+
catch (Exception e)
108+
{
109+
logger.LogCritical(e, "An unhandled exception occurred during startup-bootstrapping");
110+
return -1;
111+
}
83112
}
84113
}
85114
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// --------------------------------------------------------------------------------------------------------------------
2+
// <copyright file="IResourceLoader.cs" company="Starion Group S.A.">
3+
// Copyright (c) 2025 Starion Group S.A.
4+
//
5+
// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Théate Antoine
6+
//
7+
// This file is part of CDP4-COMET WEB Community Edition
8+
// The CDP4-COMET WEB Community Edition is the RHEA Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C.
9+
//
10+
// The CDP4-COMET WEB Community Edition is free software; you can redistribute it and/or
11+
// modify it under the terms of the GNU Affero General Public
12+
// License as published by the Free Software Foundation; either
13+
// version 3 of the License, or (at your option) any later version.
14+
//
15+
// The CDP4-COMET WEB Community Edition is distributed in the hope that it will be useful,
16+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18+
// Affero General Public License for more details.
19+
//
20+
// You should have received a copy of the GNU Affero General Public License
21+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
22+
// </copyright>
23+
// --------------------------------------------------------------------------------------------------------------------
24+
25+
namespace COMETwebapp.Resources
26+
{
27+
using System;
28+
using System.Collections.Generic;
29+
30+
/// <summary>
31+
/// Defnition of the interface used to load (embedded) resources
32+
/// </summary>
33+
public interface IResourceLoader
34+
{
35+
/// <summary>
36+
/// Load an embedded resource
37+
/// </summary>
38+
/// <param name="path">
39+
/// The path of the embedded resource
40+
/// </param>
41+
/// <returns>
42+
/// a string containing the contents of the embedded resource
43+
/// </returns>
44+
string LoadEmbeddedResource(string path);
45+
46+
/// <summary>
47+
/// queries the version number from the executing assembly
48+
/// </summary>
49+
/// <returns>
50+
/// a string representation of the version of the application
51+
/// </returns>
52+
string QueryVersion();
53+
54+
/// <summary>
55+
/// Queries the logo with version info from the embedded resources
56+
/// </summary>
57+
/// <returns>
58+
/// the logo
59+
/// </returns>
60+
string QueryLogo();
61+
}
62+
}
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
// --------------------------------------------------------------------------------------------------------------------
2+
// <copyright file="ResourceLoader.cs" company="Starion Group S.A.">
3+
// Copyright (c) 2025 Starion Group S.A.
4+
//
5+
// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine
6+
//
7+
// This file is part of CDP4-COMET WEB Community Edition
8+
// The CDP4-COMET WEB Community Edition is the RHEA Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C.
9+
//
10+
// The CDP4-COMET WEB Community Edition is free software; you can redistribute it and/or
11+
// modify it under the terms of the GNU Affero General Public
12+
// License as published by the Free Software Foundation; either
13+
// version 3 of the License, or (at your option) any later version.
14+
//
15+
// The CDP4-COMET WEB Community Edition is distributed in the hope that it will be useful,
16+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18+
// Affero General Public License for more details.
19+
//
20+
// You should have received a copy of the GNU Affero General Public License
21+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
22+
// </copyright>
23+
// --------------------------------------------------------------------------------------------------------------------
24+
25+
namespace COMETwebapp.Resources
26+
{
27+
using System;
28+
using System.Collections.Generic;
29+
using System.Diagnostics;
30+
using System.IO;
31+
using System.Reflection;
32+
using System.Resources;
33+
34+
/// <summary>
35+
/// Class responsible for loading embedded resources.
36+
/// </summary>
37+
public class ResourceLoader : IResourceLoader
38+
{
39+
/// <summary>
40+
/// Load an embedded resource
41+
/// </summary>
42+
/// <param name="path">
43+
/// The path of the embedded resource
44+
/// </param>
45+
/// <returns>
46+
/// a string containing the contents of the embedded resource
47+
/// </returns>
48+
public string LoadEmbeddedResource(string path)
49+
{
50+
var assembly = Assembly.GetExecutingAssembly();
51+
52+
using var stream = assembly.GetManifestResourceStream(path);
53+
54+
using var reader = new StreamReader(stream ?? throw new MissingManifestResourceException());
55+
56+
return reader.ReadToEnd();
57+
}
58+
59+
/// <summary>
60+
/// queries the version number from the executing assembly
61+
/// </summary>
62+
/// <returns>
63+
/// a string representation of the version of the application
64+
/// </returns>
65+
public string QueryVersion()
66+
{
67+
var assembly = Assembly.GetExecutingAssembly();
68+
69+
return this.GetAssemblyVersion(assembly);
70+
}
71+
72+
/// <summary>
73+
/// Gets the version number of an <see cref="Assembly"/>
74+
/// </summary>
75+
/// <param name="assembly">The <see cref="Assembly"/></param>
76+
/// <returns>The version number of the <see cref="Assembly"/></returns>
77+
private string GetAssemblyVersion(Assembly assembly)
78+
{
79+
var infoVersion = assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
80+
81+
if (infoVersion != null)
82+
{
83+
var plusIndex = infoVersion.InformationalVersion.IndexOf('+');
84+
85+
if (plusIndex != -1)
86+
{
87+
return infoVersion.InformationalVersion.Substring(0, plusIndex);
88+
}
89+
}
90+
91+
var fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);
92+
var productVersion = fileVersionInfo.ProductVersion;
93+
94+
if (productVersion != null)
95+
{
96+
var plusIndex = productVersion.IndexOf('+');
97+
98+
if (plusIndex != -1)
99+
{
100+
return productVersion.Substring(0, plusIndex);
101+
}
102+
}
103+
104+
return productVersion ?? "unknown";
105+
}
106+
107+
/// <summary>
108+
/// Queries the logo with version info from the embedded resources
109+
/// </summary>
110+
/// <returns>
111+
/// the logo
112+
/// </returns>
113+
public string QueryLogo()
114+
{
115+
var version = this.QueryVersion();
116+
117+
var logo = this.LoadEmbeddedResource("COMETwebapp.Resources.ascii-art.txt")
118+
.Replace("COMETWebVersion", version);
119+
120+
return logo;
121+
}
122+
}
123+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+

2+
3+
██████╗██████╗ ██████╗ ██╗ ██╗ ██████╗ ██████╗ ███╗ ███╗███████╗████████╗
4+
██╔════╝██╔══██╗██╔══██╗██║ ██║ ██╔════╝██╔═══██╗████╗ ████║██╔════╝╚══██╔══╝
5+
██║ ██║ ██║██████╔╝███████║█████╗██║ ██║ ██║██╔████╔██║█████╗ ██║
6+
██║ ██║ ██║██╔═══╝ ╚════██║╚════╝██║ ██║ ██║██║╚██╔╝██║██╔══╝ ██║
7+
╚██████╗██████╔╝██║ ██║ ╚██████╗╚██████╔╝██║ ╚═╝ ██║███████╗ ██║
8+
╚═════╝╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝ ╚═╝
9+
10+
copyright 2015-2025 STARION Group S.A. https://www.stariongroup.eu
11+
12+
CDP4-COMET WEB version: COMETWebVersion

COMETwebapp/appsettings.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
{
22
"AllowedHosts": "*",
3+
"Kestrel": {
4+
"Endpoints": {
5+
"Http": {
6+
"Url": "http://*:8080"
7+
}
8+
}
9+
},
310
"StringTablePath": "wwwroot/DefaultTextConfiguration.json",
411
"MaxUploadFileSizeInMb": 500,
512
"ServerConfiguration": {

0 commit comments

Comments
 (0)