mirror of https://github.com/mindoc-org/mindoc.git
fix:修复旧版本没有标识文档读写缓存失败的BUG
parent
b50d39f690
commit
c7251697b3
|
@ -84,6 +84,9 @@ WORKDIR /mindoc
|
||||||
|
|
||||||
COPY --from=0 /go/src/github.com/lifei6671/mindoc .
|
COPY --from=0 /go/src/github.com/lifei6671/mindoc .
|
||||||
|
|
||||||
|
# 时区设置
|
||||||
|
ENV TZ=Asia/Shanghai
|
||||||
|
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||||
|
|
||||||
ENV ZONEINFO=/mindoc/lib/time/zoneinfo.zip
|
ENV ZONEINFO=/mindoc/lib/time/zoneinfo.zip
|
||||||
RUN chmod +x start.sh
|
RUN chmod +x start.sh
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"github.com/astaxie/beego"
|
"github.com/astaxie/beego"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
var bm cache.Cache
|
var bm cache.Cache
|
||||||
|
|
||||||
func Get(key string, e interface{}) error {
|
func Get(key string, e interface{}) error {
|
||||||
|
@ -45,9 +46,6 @@ func Get(key string,e interface{}) error {
|
||||||
return errors.New("value is not []byte or string")
|
return errors.New("value is not []byte or string")
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetMulti(keys []string) []interface{} {
|
|
||||||
return bm.GetMulti(keys)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Put(key string, val interface{}, timeout time.Duration) error {
|
func Put(key string, val interface{}, timeout time.Duration) error {
|
||||||
|
|
||||||
|
@ -83,6 +81,7 @@ func ClearAll() error{
|
||||||
func StartAndGC(config string) error {
|
func StartAndGC(config string) error {
|
||||||
return bm.StartAndGC(config)
|
return bm.StartAndGC(config)
|
||||||
}
|
}
|
||||||
|
|
||||||
//初始化缓存
|
//初始化缓存
|
||||||
func Init(c cache.Cache) {
|
func Init(c cache.Cache) {
|
||||||
bm = c
|
bm = c
|
||||||
|
|
|
@ -108,8 +108,13 @@ func RegisterLogger(log string) {
|
||||||
logs.Async(1e3)
|
logs.Async(1e3)
|
||||||
}
|
}
|
||||||
if log == "" {
|
if log == "" {
|
||||||
|
logPath,err := filepath.Abs(beego.AppConfig.DefaultString("log_path",conf.WorkingDir("runtime","logs")))
|
||||||
|
if err == nil {
|
||||||
|
log = logPath
|
||||||
|
}else{
|
||||||
log = conf.WorkingDir("runtime","logs")
|
log = conf.WorkingDir("runtime","logs")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
logPath := filepath.Join(log, "log.log")
|
logPath := filepath.Join(log, "log.log")
|
||||||
|
|
||||||
|
@ -235,9 +240,7 @@ func ResolveCommand(args []string) {
|
||||||
conf.WorkingDirectory = filepath.Dir(p)
|
conf.WorkingDirectory = filepath.Dir(p)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if conf.LogFile == "" {
|
|
||||||
conf.LogFile = conf.WorkingDir("runtime","logs")
|
|
||||||
}
|
|
||||||
if conf.ConfigurationFile == "" {
|
if conf.ConfigurationFile == "" {
|
||||||
conf.ConfigurationFile = conf.WorkingDir( "conf", "app.conf")
|
conf.ConfigurationFile = conf.WorkingDir( "conf", "app.conf")
|
||||||
config := conf.WorkingDir("conf", "app.conf.example")
|
config := conf.WorkingDir("conf", "app.conf.example")
|
||||||
|
@ -252,6 +255,15 @@ func ResolveCommand(args []string) {
|
||||||
if err := beego.LoadAppConfig("ini", conf.ConfigurationFile);err != nil {
|
if err := beego.LoadAppConfig("ini", conf.ConfigurationFile);err != nil {
|
||||||
log.Fatal("An error occurred:", err)
|
log.Fatal("An error occurred:", err)
|
||||||
}
|
}
|
||||||
|
if conf.LogFile == "" {
|
||||||
|
logPath,err := filepath.Abs(beego.AppConfig.DefaultString("log_path",conf.WorkingDir("runtime","logs")))
|
||||||
|
if err == nil {
|
||||||
|
conf.LogFile = logPath
|
||||||
|
}else{
|
||||||
|
conf.LogFile = conf.WorkingDir("runtime","logs")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
conf.AutoLoadDelay = beego.AppConfig.DefaultInt("config_auto_delay",0)
|
conf.AutoLoadDelay = beego.AppConfig.DefaultInt("config_auto_delay",0)
|
||||||
uploads := conf.WorkingDir("uploads")
|
uploads := conf.WorkingDir("uploads")
|
||||||
|
|
||||||
|
@ -282,6 +294,7 @@ func RegisterCache() {
|
||||||
isOpenCache := beego.AppConfig.DefaultBool("cache", false)
|
isOpenCache := beego.AppConfig.DefaultBool("cache", false)
|
||||||
if !isOpenCache {
|
if !isOpenCache {
|
||||||
cache.Init(&cache.NullCache{})
|
cache.Init(&cache.NullCache{})
|
||||||
|
return
|
||||||
}
|
}
|
||||||
beego.Info("正常初始化缓存配置.")
|
beego.Info("正常初始化缓存配置.")
|
||||||
cacheProvider := beego.AppConfig.String("cache_provider")
|
cacheProvider := beego.AppConfig.String("cache_provider")
|
||||||
|
@ -355,13 +368,13 @@ func RegisterCache() {
|
||||||
|
|
||||||
bc, err := json.Marshal(&memcacheConfig)
|
bc, err := json.Marshal(&memcacheConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
beego.Error("初始化Redis缓存失败:", err)
|
beego.Error("初始化 Redis 缓存失败 ->", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
memcache, err := beegoCache.NewCache("memcache", string(bc))
|
memcache, err := beegoCache.NewCache("memcache", string(bc))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
beego.Error("初始化Memcache缓存失败:", err)
|
beego.Error("初始化 Memcache 缓存失败 ->", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -397,10 +410,13 @@ func RegisterAutoLoadConfig() {
|
||||||
}
|
}
|
||||||
if modTime != f.ModTime() {
|
if modTime != f.ModTime() {
|
||||||
if err := beego.LoadAppConfig("ini", conf.ConfigurationFile); err != nil {
|
if err := beego.LoadAppConfig("ini", conf.ConfigurationFile); err != nil {
|
||||||
beego.Error("An error occurred:", err)
|
beego.Error("An error occurred ->", err)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
modTime = f.ModTime()
|
modTime = f.ModTime()
|
||||||
|
RegisterCache()
|
||||||
|
|
||||||
|
RegisterLogger("")
|
||||||
beego.Info("配置文件已加载")
|
beego.Info("配置文件已加载")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,9 +179,7 @@ func (m *Document) RemoveCache() {
|
||||||
//从缓存获取
|
//从缓存获取
|
||||||
func (m *Document) FromCacheById(id int) (*Document, error) {
|
func (m *Document) FromCacheById(id int) (*Document, error) {
|
||||||
|
|
||||||
var doc Document
|
|
||||||
if err := cache.Get("Document.Id."+strconv.Itoa(id), &m); err == nil && m.DocumentId > 0 {
|
if err := cache.Get("Document.Id."+strconv.Itoa(id), &m); err == nil && m.DocumentId > 0 {
|
||||||
m = &doc
|
|
||||||
beego.Info("从缓存中获取文档信息成功 ->", m.DocumentId)
|
beego.Info("从缓存中获取文档信息成功 ->", m.DocumentId)
|
||||||
return m, nil
|
return m, nil
|
||||||
}
|
}
|
||||||
|
|
2
start.sh
2
start.sh
|
@ -5,8 +5,6 @@ cd /mindoc/
|
||||||
|
|
||||||
if [ ! -f "/mindoc/conf/app.conf" ] ; then
|
if [ ! -f "/mindoc/conf/app.conf" ] ; then
|
||||||
cp /mindoc/conf/app.conf.example /mindoc/conf/app.conf
|
cp /mindoc/conf/app.conf.example /mindoc/conf/app.conf
|
||||||
sed -i "s#^db_adapter=.*#db_adapter=sqlite3#g" conf/app.conf
|
|
||||||
sed -i "s#^db_database.*#db_database=./database/mindoc.db#g" conf/app.conf
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row text-center border-top">
|
<div class="row text-center border-top">
|
||||||
<span><a href="https://www.iminho.me" target="_blank">MinDoc</a></span>
|
<span><a href="https://www.iminho.me" target="_blank">官方网站</a></span>
|
||||||
<span> · </span>
|
<span> · </span>
|
||||||
<span><a href="https://github.com/lifei6671/mindoc/issues" target="_blank">意见反馈</a></span>
|
<span><a href="https://github.com/lifei6671/mindoc/issues" target="_blank">意见反馈</a></span>
|
||||||
<span> · </span>
|
<span> · </span>
|
||||||
<span><a href="https://github.com/lifei6671/mindoc" target="_blank">Github</a></span>
|
<span><a href="https://github.com/lifei6671/mindoc" target="_blank">项目源码</a></span>
|
||||||
|
<span> · </span>
|
||||||
|
<span><a href="https://www.iminho.me/wiki/docs/mindoc/" target="_blank">使用手册</a></span>
|
||||||
</div>
|
</div>
|
||||||
{{if ne .site_beian ""}}
|
{{if ne .site_beian ""}}
|
||||||
<div class="row text-center">
|
<div class="row text-center">
|
||||||
|
|
Loading…
Reference in New Issue