mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-16 21:33:41 +00:00
fix(web): return startup errors instead of panicking (#1620)
Replace server startup panics with returned errors, print actionable CLI messages with exit status 1, and clarify the API token flags. Add regressions for missing web authentication credentials. Fixes GopeedLab/gopeed#1614
This commit is contained in:
1 parent
903c5c46c4
commit
7d423e2182
5 files changed
+55
-9
No files matched your search
+7
-5
@@ -16,15 +16,16 @@ import (
|
||||
//go:embed banner.txt
|
||||
var banner string
|
||||
|
||||
func Start(cfg *model.StartConfig) {
|
||||
fmt.Println(banner)
|
||||
func Start(cfg *model.StartConfig) error {
|
||||
srv, listener, err := rest.BuildServer(cfg)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return err
|
||||
}
|
||||
fmt.Println(banner)
|
||||
downloadCfg, err := rest.Downloader.GetConfig()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
listener.Close()
|
||||
return err
|
||||
}
|
||||
if rest.Downloader.IsFirstLoad() {
|
||||
// Set default download config
|
||||
@@ -62,8 +63,9 @@ func Start(cfg *model.StartConfig) {
|
||||
|
||||
fmt.Printf("Server start success on http://%s\n", listener.Addr().String())
|
||||
if err := srv.Serve(listener); err != nil && err != http.ErrServerClosed {
|
||||
panic(err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func watchExit() {
|
||||
|
||||
Reference in new issue
Block a user