Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
performance
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zry
performance
Commits
8c3a2cf2
Commit
8c3a2cf2
authored
Jan 12, 2022
by
ruyun.zhang@suvalue.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'hotfix/删除历史日志'
parents
0b73f727
e9b25103
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
1 deletions
+47
-1
performance/Performance.Api/Job/ClearLoggerJob.cs
+43
-0
performance/Performance.Api/Job/JobRegistry.cs
+2
-0
performance/Performance.Api/Startup.cs
+1
-0
performance/Performance.DtoModels/SaveCollectData.cs
+1
-1
No files found.
performance/Performance.Api/Job/ClearLoggerJob.cs
0 → 100644
View file @
8c3a2cf2
using
FluentScheduler
;
using
Microsoft.AspNetCore.Hosting
;
using
Microsoft.Extensions.Logging
;
using
System
;
using
System.IO
;
namespace
Performance.Api
{
/// <summary>
/// 删除历史日志
/// </summary>
public
class
ClearLoggerJob
:
IJob
{
private
readonly
ILogger
<
ClearLoggerJob
>
_logger
;
public
ClearLoggerJob
(
ILogger
<
ClearLoggerJob
>
logger
)
{
_logger
=
logger
;
}
public
void
Execute
()
{
try
{
var
path
=
Path
.
Combine
(
AppDomain
.
CurrentDomain
.
BaseDirectory
,
"Logs"
);
if
(!
Directory
.
Exists
(
path
))
return
;
var
directories
=
Directory
.
GetDirectories
(
path
);
foreach
(
var
d
in
directories
)
{
DirectoryInfo
info
=
new
DirectoryInfo
(
d
);
if
(
info
.
LastWriteTime
<
DateTime
.
Now
.
AddMonths
(-
3
))
Directory
.
Delete
(
d
,
true
);
}
}
catch
(
Exception
ex
)
{
_logger
.
LogError
(
"删除日志异常:{ex}"
,
ex
);
}
}
}
}
performance/Performance.Api/Job/JobRegistry.cs
View file @
8c3a2cf2
...
...
@@ -19,6 +19,8 @@ public JobRegistry(IServiceProvider provider)
//Schedule<ExtractDataJob>().ToRunNow().AndEvery(1).Days().At(23, 0);
//Schedule<ExtractDataJob>().ToRunEvery(1).Days().At(23, 0);
Schedule
(()
=>
provider
.
GetService
<
ExtractGenerateJob
>()).
ToRunEvery
(
1
).
Days
().
At
(
23
,
00
);
//Schedule(() => provider.GetService<ClearLoggerJob>()).ToRunNow().AndEvery(60).Seconds();
Schedule
(()
=>
provider
.
GetService
<
ClearLoggerJob
>()).
ToRunNow
().
AndEvery
(
1
).
Days
().
At
(
3
,
00
);
}
}
}
performance/Performance.Api/Startup.cs
View file @
8c3a2cf2
...
...
@@ -99,6 +99,7 @@ public void ConfigureServices(IServiceCollection services)
services
.
AddTransient
<
ExtractGenerateJob
>();
services
.
AddTransient
<
ExtractDataJob
>();
services
.
AddTransient
<
ClearLoggerJob
>();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
...
...
performance/Performance.DtoModels/SaveCollectData.cs
View file @
8c3a2cf2
...
...
@@ -35,6 +35,6 @@ public class SaveGatherData
public
string
Source
{
get
;
set
;
}
public
string
Category
{
get
;
set
;
}
public
string
[]
ColHeaders
{
get
;
set
;
}
public
new
string
[][]
Data
{
get
;
set
;
}
public
string
[][]
Data
{
get
;
set
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment