Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2023-01-06 11:38:03 +08:00
commit 0c19a059c9
2 changed files with 6 additions and 5 deletions

View File

@ -900,6 +900,7 @@ powerMonitor.on('suspend', () => {
}) })
powerMonitor.on('resume', async () => { powerMonitor.on('resume', async () => {
// 桌面端系统休眠唤醒后判断网络连通性后再执行数据同步 https://github.com/siyuan-note/siyuan/issues/6687
writeLog('system resume') writeLog('system resume')
const isOnline = async () => { const isOnline = async () => {
try { try {
@ -931,7 +932,6 @@ powerMonitor.on('resume', async () => {
} }
writeLog('sync after system resume') writeLog('sync after system resume')
// 桌面端系统休眠唤醒后同步延时 7s 后再执行 https://github.com/siyuan-note/siyuan/issues/6687
fetch(getServer() + '/api/sync/performSync', {method: 'POST'}) fetch(getServer() + '/api/sync/performSync', {method: 'POST'})
}) })

View File

@ -108,16 +108,17 @@ func Serve(fastMode bool) {
rewritePortJSON(pid, port) rewritePortJSON(pid, port)
} }
logging.LogInfof("kernel [pid=%s] is booting [%s]", pid, "http://"+util.LocalHost+":"+port) logging.LogInfof("kernel [pid=%s] http server is booting [%s]", pid, "http://"+util.LocalHost+":"+port)
util.HttpServing = true util.HttpServing = true
go func() { go func() {
time.Sleep(1 * time.Second)
if util.FixedPort != port { if util.FixedPort != port {
// 启动一个 6806 端口的反向代理服务器,这样浏览器扩展才能直接使用 127.0.0.1:6806不用配置端口 // 启动一个 6806 端口的反向代理服务器,这样浏览器扩展才能直接使用 127.0.0.1:6806不用配置端口
serverURL, _ := url.Parse("http://" + host + ":" + port) serverURL, _ := url.Parse("http://127.0.0.1:" + port)
proxy := httputil.NewSingleHostReverseProxy(serverURL) proxy := httputil.NewSingleHostReverseProxy(serverURL)
logging.LogInfof("reverse proxy server [%s] is booting", util.FixedPort) logging.LogInfof("reverse proxy server is booting [%s]", "http://127.0.0.1:"+util.FixedPort)
if proxyErr := http.ListenAndServe(host+":"+util.FixedPort, proxy); nil != proxyErr { if proxyErr := http.ListenAndServe("127.0.0.1:"+util.FixedPort, proxy); nil != proxyErr {
logging.LogWarnf("boot reverse proxy server [%s] failed: %s", serverURL, proxyErr) logging.LogWarnf("boot reverse proxy server [%s] failed: %s", serverURL, proxyErr)
} }
// 反代服务器启动失败不影响核心服务器启动 // 反代服务器启动失败不影响核心服务器启动