public
/
ndcode_site.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
19bf677
)
Implement log file rotation
author
Nick Downing
<nick@ndcode.org>
Sat, 8 Jan 2022 03:30:33 +0000
(14:30 +1100)
committer
Nick Downing
<nick@ndcode.org>
Sun, 9 Jan 2022 00:30:05 +0000
(11:30 +1100)
_config/site.jst
patch
|
blob
|
history
diff --git
a/_config/site.jst
b/_config/site.jst
index
0298224
..
b41a6a4
100644
(file)
--- a/
_config/site.jst
+++ b/
_config/site.jst
@@
-1,5
+1,6
@@
let assert = require('assert')
let EmailJSCache = require('@ndcode/emailjs_cache')
let assert = require('assert')
let EmailJSCache = require('@ndcode/emailjs_cache')
+let XDate = require('xdate')
let ZettairCache = require('@ndcode/zettair_cache')
return async (resources, root, prev_site) => {
let ZettairCache = require('@ndcode/zettair_cache')
return async (resources, root, prev_site) => {
@@
-11,6
+12,7
@@
return async (resources, root, prev_site) => {
_jst_server.Site.call(this, resources, root, options, prev_site)
this.database = undefined
_jst_server.Site.call(this, resources, root, options, prev_site)
this.database = undefined
+ this.database_date = new XDate().toUTCString('yyyyMMdd')
this.emailjs_cache = undefined
this.zettair_cache = undefined
}
this.emailjs_cache = undefined
this.zettair_cache = undefined
}
@@
-67,7
+69,19
@@
return async (resources, root, prev_site) => {
await _jst_server.Site.prototype.kick.call(this)
assert(this.database !== undefined)
await _jst_server.Site.prototype.kick.call(this)
assert(this.database !== undefined)
- this.database.kick()
+ await this.database.kick()
+
+ let new_database_date = new XDate().toUTCString('yyyyMMdd')
+ if (new_database_date !== this.database_date) {
+ console.log(
+ 'rotate database',
+ this.database_date,
+ '->',
+ new_database_date
+ )
+ await this.database.rotate('database.logjson.' + this.database_date)
+ this.database_date = new_database_date
+ }
assert(this.emailjs_cache !== undefined)
this.emailjs_cache.kick()
assert(this.emailjs_cache !== undefined)
this.emailjs_cache.kick()