Skip to content

Commit

Permalink
fix: remove UserService (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeessy2 authored Jul 8, 2024
1 parent 0714eee commit c3c7423
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func main() {
uninstallService()
default:
if util.IsRunInDocker() {
run(100 * time.Millisecond)
run()
} else {
s := getService()
status, _ := s.Status()
Expand All @@ -67,7 +67,7 @@ func main() {
default:
log.Println("可使用 ./backup-x -s install 安装服务运行")
}
run(100 * time.Millisecond)
run()
}
}
}
Expand All @@ -81,7 +81,7 @@ func faviconFsFunc(writer http.ResponseWriter, request *http.Request) {
http.FileServer(http.FS(faviconEmbededFile)).ServeHTTP(writer, request)
}

func run(firstDelay time.Duration) {
func run() {
// 启动静态文件服务
http.HandleFunc("/static/", web.BasicAuth(staticFsFunc))
http.HandleFunc("/favicon.ico", web.BasicAuth(faviconFsFunc))
Expand Down Expand Up @@ -116,7 +116,8 @@ func (p *program) Start(s service.Service) error {
}
func (p *program) run() {
// 服务运行,延时20秒运行,等待网络
run(20 * time.Second)
time.Sleep(20 * time.Second)
run()
}
func (p *program) Stop(s service.Service) error {
// Stop should not block. Return with a few seconds.
Expand All @@ -138,9 +139,6 @@ func getService() service.Service {
"After=network-online.target")
}

// run as user service
options["UserService"] = true

svcConfig := &service.Config{
Name: "backup-x",
DisplayName: "backup-x",
Expand Down

0 comments on commit c3c7423

Please sign in to comment.