Finish the logger maintain work.
This commit is contained in:
parent
1bdfb4996e
commit
3f668dcc4b
@ -12,6 +12,22 @@ CREATE TABLE `tank20_download_token`
|
||||
UNIQUE KEY `id_UNIQUE` (`uuid`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='下载的token表';
|
||||
|
||||
CREATE TABLE `tank20_footprint`
|
||||
(
|
||||
`uuid` char(36) NOT NULL,
|
||||
`user_uuid` char(36) DEFAULT NULL,
|
||||
`ip` varchar(45) DEFAULT NULL,
|
||||
`host` varchar(45) DEFAULT NULL,
|
||||
`uri` varchar(255) DEFAULT NULL,
|
||||
`params` text,
|
||||
`cost` int(11) DEFAULT '0' COMMENT '耗时 ms',
|
||||
`success` tinyint(1) DEFAULT '1',
|
||||
`sort` bigint(20) NOT NULL DEFAULT '0',
|
||||
`update_time` timestamp NULL DEFAULT NULL,
|
||||
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`uuid`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='访问记录表';
|
||||
|
||||
CREATE TABLE `tank20_image_cache`
|
||||
(
|
||||
`uuid` char(36) NOT NULL,
|
||||
@ -40,6 +56,7 @@ CREATE TABLE `tank20_matter`
|
||||
`size` bigint(20) DEFAULT '0' COMMENT '文件大小',
|
||||
`privacy` tinyint(1) DEFAULT '0' COMMENT '文件是否是公有的',
|
||||
`path` varchar(255) DEFAULT NULL,
|
||||
`times` bigint(20) DEFAULT '0' COMMENT '下载次数',
|
||||
`sort` bigint(20) DEFAULT NULL,
|
||||
`update_time` timestamp NULL DEFAULT NULL,
|
||||
`create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
@ -63,33 +80,15 @@ CREATE TABLE `tank20_preference`
|
||||
UNIQUE KEY `id_UNIQUE` (`uuid`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='网站偏好设置表';
|
||||
|
||||
CREATE TABLE `tank20_security_visit`
|
||||
(
|
||||
`uuid` char(36) NOT NULL,
|
||||
`session_id` varchar(45) DEFAULT NULL,
|
||||
`user_uuid` char(36) DEFAULT NULL,
|
||||
`ip` varchar(45) DEFAULT NULL,
|
||||
`host` varchar(45) DEFAULT NULL,
|
||||
`uri` varchar(255) DEFAULT NULL,
|
||||
`params` text,
|
||||
`cost` int(11) DEFAULT '0' COMMENT '耗时 ms',
|
||||
`success` tinyint(1) DEFAULT '1',
|
||||
`sort` bigint(20) NOT NULL DEFAULT '0',
|
||||
`update_time` timestamp NULL DEFAULT NULL,
|
||||
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`uuid`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='访问记录表';
|
||||
|
||||
CREATE TABLE `tank20_session`
|
||||
(
|
||||
`uuid` char(36) NOT NULL,
|
||||
`authentication` char(36) DEFAULT NULL COMMENT '认证身份,存放在cookie中',
|
||||
`user_uuid` char(36) DEFAULT NULL COMMENT '用户uuid',
|
||||
`ip` varchar(45) DEFAULT NULL COMMENT '用户的ip地址',
|
||||
`expire_time` timestamp NULL DEFAULT NULL,
|
||||
`sort` bigint(20) DEFAULT NULL,
|
||||
`update_time` timestamp NULL DEFAULT NULL,
|
||||
`create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`uuid` char(36) NOT NULL,
|
||||
`user_uuid` char(36) DEFAULT NULL COMMENT '用户uuid',
|
||||
`ip` varchar(45) DEFAULT NULL COMMENT '用户的ip地址',
|
||||
`expire_time` timestamp NULL DEFAULT NULL,
|
||||
`sort` bigint(20) DEFAULT NULL,
|
||||
`update_time` timestamp NULL DEFAULT NULL,
|
||||
`create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
PRIMARY KEY (`uuid`),
|
||||
UNIQUE KEY `id_UNIQUE` (`uuid`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='session表';
|
||||
@ -131,5 +130,7 @@ CREATE TABLE `tank20_user`
|
||||
`update_time` timestamp NULL DEFAULT NULL,
|
||||
`create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
PRIMARY KEY (`uuid`),
|
||||
UNIQUE KEY `id_UNIQUE` (`uuid`)
|
||||
UNIQUE KEY `id_UNIQUE` (`uuid`),
|
||||
UNIQUE KEY `email_UNIQUE` (`email`),
|
||||
UNIQUE KEY `username_UNIQUE` (`username`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户表描述';
|
||||
|
@ -67,6 +67,7 @@ func (this *Logger) Init() {
|
||||
//日志需要自我备份,自我维护。明天第一秒触发
|
||||
nextTime := FirstSecondOfDay(Tomorrow())
|
||||
duration := nextTime.Sub(time.Now())
|
||||
go this.Info("%vs后将进行下一次日志维护 下次时间%v ", int64(duration/time.Second), nextTime)
|
||||
this.maintainTimer = time.AfterFunc(duration, func() {
|
||||
go this.maintain()
|
||||
})
|
||||
@ -100,12 +101,12 @@ func (this *Logger) maintain() {
|
||||
now := time.Now()
|
||||
nextTime := FirstSecondOfDay(Tomorrow())
|
||||
duration := nextTime.Sub(now)
|
||||
go this.Info("%vs后将进行下一次日志维护 下次时间维护时间:%v ", int64(duration/time.Second), nextTime)
|
||||
this.maintainTimer = time.AfterFunc(duration, func() {
|
||||
go this.maintain()
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
//日志名称
|
||||
func (this *Logger) fileName() string {
|
||||
return GetLogPath() + "/tank.log"
|
||||
|
@ -30,13 +30,13 @@ func FirstSecondOfDay(day time.Time) time.Time {
|
||||
//明天此刻的时间
|
||||
func Tomorrow() time.Time {
|
||||
tomorrow := time.Now()
|
||||
tomorrow.AddDate(0, 0, 1)
|
||||
tomorrow = tomorrow.AddDate(0, 0, 1)
|
||||
return tomorrow
|
||||
}
|
||||
|
||||
//昨天此刻的时间
|
||||
func Yesterday() time.Time {
|
||||
tomorrow := time.Now()
|
||||
tomorrow.AddDate(0, 0, -1)
|
||||
tomorrow = tomorrow.AddDate(0, 0, -1)
|
||||
return tomorrow
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user