Skip to content

Commit bc25e58

Browse files
author
Arnaud Bouchez
committed
define TSynDaemonAbstractSettings abstract parent class
no property is published at this level to let inherited classes define the values customizable from JSON serialization
1 parent 05e01f0 commit bc25e58

File tree

2 files changed

+32
-11
lines changed

2 files changed

+32
-11
lines changed

src/app/mormot.app.daemon.pas

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ interface
3838
type
3939
/// abstract parent containing information able to initialize a TSynDaemon class
4040
// - will handle persistence as JSON local files
41-
// - you may consider using TDDDAppSettingsAbstract from dddInfraSettings
42-
TSynDaemonSettings = class(TSynJsonFileSettings)
41+
// - by default in this abstract parent class, no property is published to let
42+
// inherited classes define the values customizable from JSON serialization
43+
TSynDaemonAbstractSettings = class(TSynJsonFileSettings)
4344
protected
4445
fServiceName: string;
4546
fServiceDisplayName: string;
@@ -68,7 +69,6 @@ TSynDaemonSettings = class(TSynJsonFileSettings)
6869
// - several depending services may be set by appending #0 between names
6970
property ServiceDependencies: string
7071
read fServiceDependencies write fServiceDependencies;
71-
published
7272
/// the service name, as used internally by Windows or the TSynDaemon class
7373
// - default is the executable name
7474
property ServiceName: string
@@ -87,9 +87,30 @@ TSynDaemonSettings = class(TSynJsonFileSettings)
8787
property LogRotateFileCount: integer
8888
read fLogRotateFileCount write fLogRotateFileCount;
8989
end;
90+
91+
/// abstract parent containing information able to initialize a TSynDaemon class
92+
// - by default, will publish the principal properties to that RTTI will handle
93+
// persistence as JSON local files
94+
TSynDaemonSettings = class(TSynDaemonAbstractSettings)
95+
published
96+
/// the service name, as used internally by Windows or the TSynDaemon class
97+
// - default is the executable name
98+
property ServiceName;
99+
/// the service name, as displayed by Windows or at the console level
100+
// - default is the executable name
101+
property ServiceDisplayName;
102+
/// if not void, will enable the logs (default is LOG_STACKTRACE)
103+
property Log: TSynLogInfos
104+
read fLog write fLog;
105+
/// allow to customize where the logs should be written
106+
property LogPath: TFileName
107+
read fLogPath write fLogPath;
108+
/// how many files will be rotated (default is 2)
109+
property LogRotateFileCount;
110+
end;
90111

91112
/// meta-class of TSynDaemon settings information
92-
TSynDaemonSettingsClass = class of TSynDaemonSettings;
113+
TSynDaemonSettingsClass = class of TSynDaemonAbstractSettings;
93114

94115

95116

@@ -106,7 +127,7 @@ TSynDaemon = class(TSynPersistent)
106127
protected
107128
fConsoleMode: boolean;
108129
fWorkFolderName: TFileName;
109-
fSettings: TSynDaemonSettings;
130+
fSettings: TSynDaemonAbstractSettings;
110131
function CustomCommandLineSyntax: string; virtual;
111132
{$ifdef OSWINDOWS}
112133
procedure DoStart(Sender: TService);
@@ -137,7 +158,7 @@ TSynDaemon = class(TSynPersistent)
137158
read fConsoleMode;
138159
/// the settings associated with this daemon
139160
// - will be allocated in Create constructor, and released in Destroy
140-
property Settings: TSynDaemonSettings
161+
property Settings: TSynDaemonAbstractSettings
141162
read fSettings;
142163
end;
143164

@@ -148,9 +169,9 @@ implementation
148169

149170
{ ************ Parent Daemon Settings Class }
150171

151-
{ TSynDaemonSettings }
172+
{ TSynDaemonAbstractSettings }
152173

153-
constructor TSynDaemonSettings.Create;
174+
constructor TSynDaemonAbstractSettings.Create;
154175
begin
155176
inherited Create;
156177
fLog := LOG_STACKTRACE + [sllNewRun];
@@ -159,7 +180,7 @@ constructor TSynDaemonSettings.Create;
159180
fServiceDisplayName := fServiceName;
160181
end;
161182

162-
function TSynDaemonSettings.ServiceDescription: string;
183+
function TSynDaemonAbstractSettings.ServiceDescription: string;
163184
var
164185
versionnumber: string;
165186
begin
@@ -174,7 +195,7 @@ function TSynDaemonSettings.ServiceDescription: string;
174195
end;
175196
end;
176197

177-
procedure TSynDaemonSettings.SetLog(aLogClass: TSynLogClass);
198+
procedure TSynDaemonAbstractSettings.SetLog(aLogClass: TSynLogClass);
178199
begin
179200
if (self <> nil) and
180201
(Log <> []) and

src/mormot.commit.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
'2.0.68'
1+
'2.0.69'

0 commit comments

Comments
 (0)