mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
🎨 Improve boot logging for database
This commit is contained in:
parent
2d8152381c
commit
c925f06326
4 changed files with 20 additions and 7 deletions
|
|
@ -29,7 +29,6 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/88250/go-humanize"
|
|
||||||
"github.com/88250/gulu"
|
"github.com/88250/gulu"
|
||||||
"github.com/88250/lute"
|
"github.com/88250/lute"
|
||||||
"github.com/88250/lute/ast"
|
"github.com/88250/lute/ast"
|
||||||
|
|
@ -834,7 +833,8 @@ func (conf *AppConf) language(num int) (ret string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func InitBoxes() {
|
func InitBoxes() {
|
||||||
initialized := 0 < treenode.CountBlocks()
|
blockCount := treenode.CountBlocks()
|
||||||
|
initialized := 0 < blockCount
|
||||||
for _, box := range Conf.GetOpenedBoxes() {
|
for _, box := range Conf.GetOpenedBoxes() {
|
||||||
box.UpdateHistoryGenerated() // 初始化历史生成时间为当前时间
|
box.UpdateHistoryGenerated() // 初始化历史生成时间为当前时间
|
||||||
|
|
||||||
|
|
@ -843,11 +843,7 @@ func InitBoxes() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var dbSize string
|
logging.LogInfof("tree/block count [%d/%d]", treenode.CountTrees(), blockCount)
|
||||||
if dbFile, err := os.Stat(util.DBPath); err == nil {
|
|
||||||
dbSize = humanize.BytesCustomCeil(uint64(dbFile.Size()), 2)
|
|
||||||
}
|
|
||||||
logging.LogInfof("database size [%s], tree/block count [%d/%d]", dbSize, treenode.CountTrees(), treenode.CountBlocks())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsSubscriber() bool {
|
func IsSubscriber() bool {
|
||||||
|
|
|
||||||
|
|
@ -225,6 +225,8 @@ func initDBConnection() {
|
||||||
if nil != db {
|
if nil != db {
|
||||||
closeDatabase()
|
closeDatabase()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
util.LogDatabaseSize(util.DBPath)
|
||||||
dsn := util.DBPath + "?_journal_mode=WAL" +
|
dsn := util.DBPath + "?_journal_mode=WAL" +
|
||||||
"&_synchronous=OFF" +
|
"&_synchronous=OFF" +
|
||||||
"&_mmap_size=2684354560" +
|
"&_mmap_size=2684354560" +
|
||||||
|
|
@ -272,6 +274,7 @@ func initHistoryDBConnection() {
|
||||||
historyDB.Close()
|
historyDB.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
util.LogDatabaseSize(util.HistoryDBPath)
|
||||||
dsn := util.HistoryDBPath + "?_journal_mode=WAL" +
|
dsn := util.HistoryDBPath + "?_journal_mode=WAL" +
|
||||||
"&_synchronous=OFF" +
|
"&_synchronous=OFF" +
|
||||||
"&_mmap_size=2684354560" +
|
"&_mmap_size=2684354560" +
|
||||||
|
|
@ -327,6 +330,7 @@ func initAssetContentDBConnection() {
|
||||||
assetContentDB.Close()
|
assetContentDB.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
util.LogDatabaseSize(util.AssetContentDBPath)
|
||||||
dsn := util.AssetContentDBPath + "?_journal_mode=WAL" +
|
dsn := util.AssetContentDBPath + "?_journal_mode=WAL" +
|
||||||
"&_synchronous=OFF" +
|
"&_synchronous=OFF" +
|
||||||
"&_mmap_size=2684354560" +
|
"&_mmap_size=2684354560" +
|
||||||
|
|
|
||||||
|
|
@ -96,6 +96,8 @@ func initDBConnection() {
|
||||||
if nil != db {
|
if nil != db {
|
||||||
closeDatabase()
|
closeDatabase()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
util.LogDatabaseSize(util.BlockTreeDBPath)
|
||||||
dsn := util.BlockTreeDBPath + "?_journal_mode=WAL" +
|
dsn := util.BlockTreeDBPath + "?_journal_mode=WAL" +
|
||||||
"&_synchronous=OFF" +
|
"&_synchronous=OFF" +
|
||||||
"&_mmap_size=2684354560" +
|
"&_mmap_size=2684354560" +
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ import (
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/88250/go-humanize"
|
||||||
"github.com/88250/gulu"
|
"github.com/88250/gulu"
|
||||||
figure "github.com/common-nighthawk/go-figure"
|
figure "github.com/common-nighthawk/go-figure"
|
||||||
"github.com/gofrs/flock"
|
"github.com/gofrs/flock"
|
||||||
|
|
@ -500,3 +501,13 @@ func UnlockWorkspace() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func LogDatabaseSize(dbPath string) {
|
||||||
|
dbFile, err := os.Stat(dbPath)
|
||||||
|
if nil != err {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
dbSize := humanize.BytesCustomCeil(uint64(dbFile.Size()), 2)
|
||||||
|
logging.LogInfof("database [%s] size [%s]", dbPath, dbSize)
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue