mirror of
https://github.com/OpenListTeam/OpenList.git
synced 2025-07-18 17:38:07 +08:00

* Enable blank issue * chore(README.md): update docs (temporally) * Update FUNDING.yml * chore: purge README.md * chore: change module name to OpenListTeam/OpenList * fix: fix link errors * chore: remove v3 in module name * fix: resolve some conficts * fix: resolve conficts * docs: update with latest file --------- Co-authored-by: ShenLin <773933146@qq.com> Co-authored-by: Hantong Chen <cxwdyx620@gmail.com> Co-authored-by: joshua <i@joshua.su> Co-authored-by: Hantong Chen <70561268+cxw620@users.noreply.github.com>
52 lines
1018 B
Go
52 lines
1018 B
Go
package cmd
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"strconv"
|
|
|
|
"github.com/OpenListTeam/OpenList/internal/bootstrap"
|
|
"github.com/OpenListTeam/OpenList/internal/bootstrap/data"
|
|
"github.com/OpenListTeam/OpenList/internal/db"
|
|
"github.com/OpenListTeam/OpenList/pkg/utils"
|
|
log "github.com/sirupsen/logrus"
|
|
)
|
|
|
|
func Init() {
|
|
bootstrap.InitConfig()
|
|
bootstrap.Log()
|
|
bootstrap.InitDB()
|
|
data.InitData()
|
|
bootstrap.InitStreamLimit()
|
|
bootstrap.InitIndex()
|
|
bootstrap.InitUpgradePatch()
|
|
}
|
|
|
|
func Release() {
|
|
db.Close()
|
|
}
|
|
|
|
var pid = -1
|
|
var pidFile string
|
|
|
|
func initDaemon() {
|
|
ex, err := os.Executable()
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
exPath := filepath.Dir(ex)
|
|
_ = os.MkdirAll(filepath.Join(exPath, "daemon"), 0700)
|
|
pidFile = filepath.Join(exPath, "daemon/pid")
|
|
if utils.Exists(pidFile) {
|
|
bytes, err := os.ReadFile(pidFile)
|
|
if err != nil {
|
|
log.Fatal("failed to read pid file", err)
|
|
}
|
|
id, err := strconv.Atoi(string(bytes))
|
|
if err != nil {
|
|
log.Fatal("failed to parse pid data", err)
|
|
}
|
|
pid = id
|
|
}
|
|
}
|