An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:memo: 内核参数增加 `--port` https://github.com/siyuan-note/siyuan/issues/6344
Liang Dinga20a19182b41
diff --git a/kernel/util/path.go b/kernel/util/path.goindex 04dd913d68..05cab8ca7c 100644--- a/kernel/util/path.go+++ b/kernel/util/path.go@@ -34,7 +34,6 @@ var ()const (- ServerPort = "0" // HTTP/WebSocket 端口AliyunServer = "https://siyuan-sync.b3logfile.com" // 云端服务地址,阿里云负载均衡,用于接口,数据同步文件上传、下载会走七牛云 OSS http://siyuan-data.b3logfile.comBazaarStatServer = "http://bazaar.b3logfile.com" // 集市包统计服务地址,直接对接 Bucket 没有 CDN 缓存BazaarOSSServer = "https://oss.b3logfile.com" // 云端对象存储地址,七牛云,仅用于读取集市包diff --git a/kernel/util/web.go b/kernel/util/web.goindex 616b47c259..77061df5d4 100644--- a/kernel/util/web.go+++ b/kernel/util/web.go@@ -24,7 +24,6 @@ import ("github.com/88250/gulu""github.com/gin-gonic/gin""github.com/olahol/melody"- "github.com/siyuan-note/logging")func GetRemoteAddr(session *melody.Session) string {@@ -64,22 +63,3 @@ func isPortOpen(port string) bool {}return false}--func tryToListenPort() bool {- listener, err := net.Listen("tcp", "127.0.0.1:"+ServerPort)- if nil != err {- time.Sleep(time.Second * 3)- listener, err = net.Listen("tcp", "127.0.0.1:"+ServerPort)- if nil != err {- logging.LogErrorf("try to listen port [%s] failed: %s", ServerPort, err)- return false- }- }- if err = listener.Close(); nil != err {- time.Sleep(time.Second * 1)- if err = listener.Close(); nil != err {- logging.LogErrorf("close listen port [%s] failed: %s", ServerPort, err)- }- }- return true-}diff --git a/kernel/util/working.go b/kernel/util/working.goindex 72dd02561d..ab71d77557 100644--- a/kernel/util/working.go+++ b/kernel/util/working.go@@ -60,6 +60,7 @@ func Boot() {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.Bool("resident", true, "resident memory even if no active session")readOnly := flag.Bool("readonly", false, "read-only mode")accessAuthCode := flag.String("accessAuthCode", "", "access auth code")@@ -76,6 +77,10 @@ func Boot() {}Mode = *modeResident = *resident+ ServerPort = *port+ if isRunningInDockerContainer() {+ ServerPort = "6806"+ }ReadOnly = *readOnlyAccessAuthCode = *accessAuthCodeContainer = ContainerStd@@ -104,7 +109,6 @@ func Boot() {}initPathDir()- checkPort()go initPandoc()bootBanner := figure.NewColorFigure("SiYuan", "isometric3", "green", true)@@ -272,6 +276,7 @@ func initWorkspaceDir(workspaceArg string) {}var (+ ServerPort = "0" // HTTP/WebSocket 端口,0 为使用随机端口Resident boolReadOnly boolAccessAuthCode string@@ -320,60 +325,6 @@ func initPathDir() {}}-func checkPort() {- portOpened := isPortOpen(ServerPort)- if !portOpened {- return- }-- logging.LogInfof("port [%s] is opened, try to check version of running kernel", ServerPort)- result := NewResult()- _, err := httpclient.NewBrowserRequest().- SetResult(result).- SetHeader("User-Agent", UserAgent).- Get("http://127.0.0.1:" + ServerPort + "/api/system/version")- if nil != err || 0 != result.Code {- logging.LogErrorf("connect to port [%s] for checking running kernel failed", ServerPort)- KillByPort(ServerPort)- return- }-- if nil == result.Data {- logging.LogErrorf("connect ot port [%s] for checking running kernel failed", ServerPort)- os.Exit(ExitCodeUnavailablePort)- }-- runningVer := result.Data.(string)- if runningVer == Ver {- logging.LogInfof("version of the running kernel is the same as this boot [%s], exit this boot", runningVer)- os.Exit(ExitCodeOk)- }-- logging.LogInfof("found kernel [%s] is running, try to exit it", runningVer)- processes, err := goPS.Processes()- if nil != err {- logging.LogErrorf("close kernel [%s] failed: %s", runningVer, err)- os.Exit(ExitCodeUnavailablePort)- }-- currentPid := os.Getpid()- for _, p := range processes {- name := p.Executable()- if strings.Contains(strings.ToLower(name), "siyuan-kernel") || strings.Contains(strings.ToLower(name), "siyuan kernel") {- kernelPid := p.Pid()- if currentPid != kernelPid {- pid := strconv.Itoa(kernelPid)- Kill(pid)- logging.LogInfof("killed kernel [name=%s, pid=%s, ver=%s], continue to boot", name, pid, runningVer)- }- }- }-- if !tryToListenPort() {- os.Exit(ExitCodeUnavailablePort)- }-}-func initMime() {// 在某版本的 Windows 10 操作系统上界面样式异常问题// https://github.com/siyuan-note/siyuan/issues/247diff --git a/kernel/util/working_mobile.go b/kernel/util/working_mobile.goindex e3beefc9b2..82ae0c7890 100644--- a/kernel/util/working_mobile.go+++ b/kernel/util/working_mobile.go@@ -61,6 +61,7 @@ func BootMobile(container, appDir, workspaceDir, nativeLibDir, privateDataDir, lThemesPath = filepath.Join(AppearancePath, "themes")IconsPath = filepath.Join(AppearancePath, "icons")Resident = true+ ServerPort = "6806"Container = containerUserAgent = UserAgent + " " + Containerhttpclient.SetUserAgent(UserAgent)