From 3bd6c3fb2083964e31819394c425e00d7640cc60 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Fri, 28 Oct 2022 19:19:09 +0800 Subject: [PATCH] =?UTF-8?q?:fire:=20=E7=A7=BB=E9=99=A4=20`--resident`=20?= =?UTF-8?q?=E5=92=8C=20`--servePath`=20=E5=86=85=E6=A0=B8=E5=8F=82?= =?UTF-8?q?=E6=95=B0=20Fix=20https://github.com/siyuan-note/siyuan/issues/?= =?UTF-8?q?6389?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/electron/main.js | 1 - kernel/main.go | 1 - kernel/model/process.go | 28 ---------------------------- kernel/util/runtime.go | 3 +-- kernel/util/working.go | 5 ----- kernel/util/working_mobile.go | 1 - 6 files changed, 1 insertion(+), 38 deletions(-) diff --git a/app/electron/main.js b/app/electron/main.js index eae7f2e4b..0930c6602 100644 --- a/app/electron/main.js +++ b/app/electron/main.js @@ -532,7 +532,6 @@ const initKernel = (initData) => { } const cmds = ['--wd', appDir] - cmds.push('--resident', 'false') if (isDevEnv) { cmds.push('--mode', 'dev') } diff --git a/kernel/main.go b/kernel/main.go index f5d94b068..9946462d4 100644 --- a/kernel/main.go +++ b/kernel/main.go @@ -50,7 +50,6 @@ func main() { go sql.AutoFlushTreeQueue() go treenode.AutoFlushBlockTree() go cache.LoadAssets() - go model.HookResident() model.WatchAssets() model.HandleSignal() } diff --git a/kernel/model/process.go b/kernel/model/process.go index 85827eeb4..7ce0f82e8 100644 --- a/kernel/model/process.go +++ b/kernel/model/process.go @@ -20,38 +20,10 @@ import ( "os" "os/signal" "syscall" - "time" "github.com/siyuan-note/logging" - "github.com/siyuan-note/siyuan/kernel/util" ) -func HookResident() { - if util.Resident { - return - } - - for range time.Tick(time.Second * 30) { - if makeSureSessionEmpty() { - logging.LogInfof("no active session, exit kernel process now") - Close(false, 1) - } - } -} - -func makeSureSessionEmpty() bool { - count := 0 - for i := 0; i < 7; i++ { - count = util.CountSessions() - //logging.LogDebugf("session count [%d]", count) - if 0 < count { - return false - } - time.Sleep(time.Second * 1) - } - return true -} - func HandleSignal() { c := make(chan os.Signal) signal.Notify(c, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGTERM) diff --git a/kernel/util/runtime.go b/kernel/util/runtime.go index 5ac9d82af..e9de5cdc9 100644 --- a/kernel/util/runtime.go +++ b/kernel/util/runtime.go @@ -47,7 +47,6 @@ func logBootInfo() { logging.LogInfof("kernel is booting:\n"+ " * ver [%s]\n"+ " * arch [%s]\n"+ - " * resident [%v]\n"+ " * pid [%d]\n"+ " * runtime mode [%s]\n"+ " * working directory [%s]\n"+ @@ -55,7 +54,7 @@ func logBootInfo() { " * container [%s]\n"+ " * database [ver=%s]\n"+ " * workspace directory [%s, data %s]", - Ver, runtime.GOARCH, Resident, os.Getpid(), Mode, WorkingDir, ReadOnly, Container, DatabaseVer, WorkspaceDir, dataDirSize) + Ver, runtime.GOARCH, os.Getpid(), Mode, WorkingDir, ReadOnly, Container, DatabaseVer, WorkspaceDir, dataDirSize) } func IsMutexLocked(m *sync.Mutex) bool { diff --git a/kernel/util/working.go b/kernel/util/working.go index 481a24fc2..5bcc2167e 100644 --- a/kernel/util/working.go +++ b/kernel/util/working.go @@ -58,10 +58,7 @@ func Boot() { workspacePath := flag.String("workspace", "", "dir path of the workspace, default to ~/Documents/SiYuan/") wdPath := flag.String("wd", WorkingDir, "working directory of SiYuan") - servePath := flag.String("servePath", "", "obsoleted https://github.com/siyuan-note/siyuan/issues/4647") - _ = servePath port := flag.String("port", "0", "port of the HTTP server") - resident := flag.String("resident", "true", "resident memory even if no active session") readOnly := flag.String("readonly", "false", "read-only mode") accessAuthCode := flag.String("accessAuthCode", "", "access auth code") ssl := flag.Bool("ssl", false, "for https and wss") @@ -76,7 +73,6 @@ func Boot() { Lang = *lang } Mode = *mode - Resident, _ = strconv.ParseBool(*resident) ServerPort = *port ReadOnly, _ = strconv.ParseBool(*readOnly) AccessAuthCode = *accessAuthCode @@ -280,7 +276,6 @@ func initWorkspaceDir(workspaceArg string) { var ( ServerPort = "0" // HTTP/WebSocket 端口,0 为使用随机端口 - Resident bool ReadOnly bool AccessAuthCode string Lang = "" diff --git a/kernel/util/working_mobile.go b/kernel/util/working_mobile.go index 377f1ae8f..16b06723c 100644 --- a/kernel/util/working_mobile.go +++ b/kernel/util/working_mobile.go @@ -61,7 +61,6 @@ func BootMobile(container, appDir, workspaceDir, nativeLibDir, privateDataDir, l ThemesPath = filepath.Join(AppearancePath, "themes") IconsPath = filepath.Join(AppearancePath, "icons") SnippetsPath = filepath.Join(DataDir, "snippets") - Resident = true ServerPort = FixedPort Container = container UserAgent = UserAgent + " " + Container