mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 15:10:12 +01:00
🎨 Improve http server
Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
parent
21dff696cc
commit
106a679dba
3 changed files with 10 additions and 1 deletions
|
|
@ -745,6 +745,9 @@ func Close(force, setCurrentWorkspace bool, execInstallPkg int) (exitCode int) {
|
||||||
if nil != util.WebSocketServer {
|
if nil != util.WebSocketServer {
|
||||||
util.WebSocketServer.Close()
|
util.WebSocketServer.Close()
|
||||||
}
|
}
|
||||||
|
if nil != util.HttpServer {
|
||||||
|
util.HttpServer.Close()
|
||||||
|
}
|
||||||
util.HttpServing = false
|
util.HttpServing = false
|
||||||
|
|
||||||
if util.ContainerAndroid == util.Container {
|
if util.ContainerAndroid == util.Container {
|
||||||
|
|
|
||||||
|
|
@ -217,7 +217,11 @@ func Serve(fastMode bool) {
|
||||||
// 反代服务器启动失败不影响核心服务器启动
|
// 反代服务器启动失败不影响核心服务器启动
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if err = http.Serve(ln, ginServer.Handler()); err != nil {
|
util.HttpServer = &http.Server{
|
||||||
|
Handler: ginServer,
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = util.HttpServer.Serve(ln); err != nil {
|
||||||
if !fastMode {
|
if !fastMode {
|
||||||
logging.LogErrorf("boot kernel failed: %s", err)
|
logging.LogErrorf("boot kernel failed: %s", err)
|
||||||
os.Exit(logging.ExitCodeUnavailablePort)
|
os.Exit(logging.ExitCodeUnavailablePort)
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"mime"
|
"mime"
|
||||||
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -72,6 +73,7 @@ func initEnvVars() {
|
||||||
var (
|
var (
|
||||||
bootProgress = atomic.Int32{} // 启动进度,从 0 到 100
|
bootProgress = atomic.Int32{} // 启动进度,从 0 到 100
|
||||||
bootDetails string // 启动细节描述
|
bootDetails string // 启动细节描述
|
||||||
|
HttpServer *http.Server // HTTP 伺服器实例
|
||||||
HttpServing = false // 是否 HTTP 伺服已经可用
|
HttpServing = false // 是否 HTTP 伺服已经可用
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue