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) => {
_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
}
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()