File tree Expand file tree Collapse file tree 1 file changed +18
-18
lines changed
src/Certify.Server/Certify.Server.HubService Expand file tree Collapse file tree 1 file changed +18
-18
lines changed Original file line number Diff line number Diff line change 57
57
#endif
58
58
59
59
// load optional config but ignore errors if it doesn't exist or is invalid, otherwise service will fail to start
60
- builder . Configuration . AddJsonFile ( p =>
61
- {
62
- p . Path = hubSettings ;
63
- p . Optional = true ;
64
- p . ReloadOnChange = true ;
65
- p . OnLoadException = e =>
66
- {
67
- e . Ignore = true ;
68
-
69
- AddSystemStatusItem (
70
- SystemStatusCategories . HUB_API ,
71
- SystemStatusKeys . HUB_API_STARTUP_CUSTOMCONFIG ,
72
- title : "Hub API Service Custom Config" ,
73
- description : $ "Error loading config file { hubSettings } - { e } ",
74
- hasError : true
75
- ) ;
76
- } ;
77
- } ) ;
60
+ if ( hubSettings != null && File . Exists ( hubSettings ) )
61
+ {
62
+ try
63
+ {
64
+ builder . Configuration . AddJsonFile ( hubSettings , optional : true , reloadOnChange : true ) ;
65
+ }
66
+ catch ( Exception ex )
67
+ {
68
+ // ignore errors loading config, we will log them later
69
+ AddSystemStatusItem (
70
+ SystemStatusCategories . HUB_API ,
71
+ SystemStatusKeys . HUB_API_STARTUP_CUSTOMCONFIG ,
72
+ title : "Hub API Service Custom Config" ,
73
+ description : $ "Error loading config file { hubSettings } - { ex } ",
74
+ hasError : true
75
+ ) ;
76
+ }
77
+ }
78
78
79
79
// if windows, run as service, otherwise run as console app
80
80
if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
You can’t perform that action at this time.
0 commit comments