mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 12:24:38 +03:00
Start browser on server start (#1832)
* Start browser on server start * Add config option for opening browser
This commit is contained in:
committed by
GitHub
parent
29b14ab4fc
commit
87036a07bc
@@ -23,6 +23,7 @@ import (
|
||||
"github.com/go-chi/chi"
|
||||
"github.com/go-chi/chi/middleware"
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/pkg/browser"
|
||||
"github.com/rs/cors"
|
||||
"github.com/stashapp/stash/pkg/logger"
|
||||
"github.com/stashapp/stash/pkg/manager"
|
||||
@@ -243,12 +244,26 @@ func Start(uiBox embed.FS, loginUIBox embed.FS) {
|
||||
printVersion()
|
||||
printLatestVersion(context.TODO())
|
||||
logger.Infof("stash is listening on " + address)
|
||||
if tlsConfig != nil {
|
||||
displayAddress = "https://" + displayAddress + "/"
|
||||
} else {
|
||||
displayAddress = "http://" + displayAddress + "/"
|
||||
}
|
||||
|
||||
// This can be done before actually starting the server, as modern browsers will
|
||||
// automatically reload the page if a local port is closed at page load and then opened.
|
||||
if !c.GetNoBrowserFlag() && manager.GetInstance().IsDesktop() {
|
||||
err = browser.OpenURL(displayAddress)
|
||||
if err != nil {
|
||||
logger.Error("Could not open browser: " + err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
if tlsConfig != nil {
|
||||
logger.Infof("stash is running at https://" + displayAddress + "/")
|
||||
logger.Infof("stash is running at " + displayAddress)
|
||||
logger.Error(server.ListenAndServeTLS("", ""))
|
||||
} else {
|
||||
logger.Infof("stash is running at http://" + displayAddress + "/")
|
||||
logger.Infof("stash is running at " + displayAddress)
|
||||
logger.Error(server.ListenAndServe())
|
||||
}
|
||||
}()
|
||||
|
||||
Reference in New Issue
Block a user