mirror of
https://github.com/idanoo/autobrr
synced 2025-07-22 16:29:12 +00:00
Feature: Set and display version info (#63)
* chore: update packages * feat: show version info * build: remove ldflags override
This commit is contained in:
parent
c65c7477fd
commit
b09796bf7e
9 changed files with 50 additions and 15 deletions
|
@ -22,8 +22,6 @@ builds:
|
|||
goarch: arm64
|
||||
main: ./cmd/autobrr/main.go
|
||||
binary: autobrr
|
||||
ldflags:
|
||||
- -s -w
|
||||
- id: autobrrctl
|
||||
env:
|
||||
- CGO_ENABLED=0
|
||||
|
@ -43,8 +41,6 @@ builds:
|
|||
goarch: arm64
|
||||
main: ./cmd/autobrrctl/main.go
|
||||
binary: autobrrctl
|
||||
ldflags:
|
||||
- -s -w
|
||||
|
||||
archives:
|
||||
- id: autobrr
|
||||
|
|
|
@ -31,7 +31,10 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
cfg domain.Config
|
||||
cfg domain.Config
|
||||
version = "dev"
|
||||
commit = ""
|
||||
date = ""
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -54,6 +57,10 @@ func main() {
|
|||
// setup logger
|
||||
logger.Setup(cfg, serverEvents)
|
||||
|
||||
log.Info().Msg("Starting autobrr")
|
||||
log.Info().Msgf("Version: %v", version)
|
||||
log.Info().Msgf("Log-level: %v", cfg.LogLevel)
|
||||
|
||||
// if configPath is set then put database inside that path, otherwise create wherever it's run
|
||||
var dataSource = database.DataSourceName(configPath, "autobrr.db")
|
||||
|
||||
|
@ -100,7 +107,7 @@ func main() {
|
|||
errorChannel := make(chan error)
|
||||
|
||||
go func() {
|
||||
httpServer := http.NewServer(serverEvents, addr, cfg.BaseURL, actionService, authService, downloadClientService, filterService, indexerService, ircService, releaseService)
|
||||
httpServer := http.NewServer(serverEvents, addr, cfg.BaseURL, version, commit, date, actionService, authService, downloadClientService, filterService, indexerService, ircService, releaseService)
|
||||
errorChannel <- httpServer.Open()
|
||||
}()
|
||||
|
||||
|
|
1
go.mod
1
go.mod
|
@ -10,7 +10,6 @@ require (
|
|||
github.com/gdm85/go-libdeluge v0.5.5
|
||||
github.com/go-chi/chi v1.5.4
|
||||
github.com/gorilla/sessions v1.2.1
|
||||
github.com/gorilla/websocket v1.4.2
|
||||
github.com/lib/pq v1.10.4
|
||||
github.com/mattn/go-isatty v0.0.14 // indirect
|
||||
github.com/pkg/errors v0.9.1
|
||||
|
|
1
go.sum
1
go.sum
|
@ -446,7 +446,6 @@ github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+
|
|||
github.com/gorilla/sessions v1.2.1 h1:DHd3rPN5lE3Ts3D8rKkQ8x/0kqfeNmBAaiSi+o7FsgI=
|
||||
github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM=
|
||||
github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
||||
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
|
||||
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/gosuri/uilive v0.0.0-20170323041506-ac356e6e42cd/go.mod h1:qkLSc0A5EXSP6B04TrN4oQoxqFI7A8XvoXSlJi8cwk8=
|
||||
github.com/gosuri/uilive v0.0.3/go.mod h1:qkLSc0A5EXSP6B04TrN4oQoxqFI7A8XvoXSlJi8cwk8=
|
||||
|
|
|
@ -14,14 +14,22 @@ type configJson struct {
|
|||
LogLevel string `json:"log_level"`
|
||||
LogPath string `json:"log_path"`
|
||||
BaseURL string `json:"base_url"`
|
||||
Version string `json:"version"`
|
||||
Commit string `json:"commit"`
|
||||
Date string `json:"date"`
|
||||
}
|
||||
|
||||
type configHandler struct {
|
||||
encoder encoder
|
||||
|
||||
server Server
|
||||
}
|
||||
|
||||
func newConfigHandler(encoder encoder) *configHandler {
|
||||
return &configHandler{encoder: encoder}
|
||||
func newConfigHandler(encoder encoder, server Server) *configHandler {
|
||||
return &configHandler{
|
||||
encoder: encoder,
|
||||
server: server,
|
||||
}
|
||||
}
|
||||
|
||||
func (h configHandler) Routes(r chi.Router) {
|
||||
|
@ -39,6 +47,9 @@ func (h configHandler) getConfig(w http.ResponseWriter, r *http.Request) {
|
|||
LogLevel: c.LogLevel,
|
||||
LogPath: c.LogPath,
|
||||
BaseURL: c.BaseURL,
|
||||
Version: h.server.version,
|
||||
Commit: h.server.commit,
|
||||
Date: h.server.date,
|
||||
}
|
||||
|
||||
h.encoder.StatusResponse(ctx, w, conf, http.StatusOK)
|
||||
|
|
|
@ -19,6 +19,10 @@ type Server struct {
|
|||
address string
|
||||
baseUrl string
|
||||
|
||||
version string
|
||||
commit string
|
||||
date string
|
||||
|
||||
actionService actionService
|
||||
authService authService
|
||||
downloadClientService downloadClientService
|
||||
|
@ -28,11 +32,14 @@ type Server struct {
|
|||
releaseService releaseService
|
||||
}
|
||||
|
||||
func NewServer(sse *sse.Server, address string, baseUrl string, actionService actionService, authService authService, downloadClientSvc downloadClientService, filterSvc filterService, indexerSvc indexerService, ircSvc ircService, releaseSvc releaseService) Server {
|
||||
func NewServer(sse *sse.Server, address string, baseUrl string, version string, commit string, date string, actionService actionService, authService authService, downloadClientSvc downloadClientService, filterSvc filterService, indexerSvc indexerService, ircSvc ircService, releaseSvc releaseService) Server {
|
||||
return Server{
|
||||
sse: sse,
|
||||
address: address,
|
||||
baseUrl: baseUrl,
|
||||
version: version,
|
||||
commit: commit,
|
||||
date: date,
|
||||
|
||||
actionService: actionService,
|
||||
authService: authService,
|
||||
|
@ -91,7 +98,7 @@ func (s Server) Handler() http.Handler {
|
|||
|
||||
r.Route("/api", func(r chi.Router) {
|
||||
r.Route("/actions", newActionHandler(encoder, s.actionService).Routes)
|
||||
r.Route("/config", newConfigHandler(encoder).Routes)
|
||||
r.Route("/config", newConfigHandler(encoder, s).Routes)
|
||||
r.Route("/download_clients", newDownloadClientHandler(encoder, s.downloadClientService).Routes)
|
||||
r.Route("/filters", newFilterHandler(encoder, s.filterService).Routes)
|
||||
r.Route("/irc", newIrcHandler(encoder, s.ircService).Routes)
|
||||
|
|
|
@ -50,7 +50,4 @@ func Setup(cfg domain.Config, sse *sse.Server) {
|
|||
|
||||
log.Logger = log.Hook(&ServerSentEventHook{sse: sse})
|
||||
log.Logger = log.Output(writers)
|
||||
|
||||
log.Print("Starting autobrr")
|
||||
log.Printf("Log-level: %v", cfg.LogLevel)
|
||||
}
|
||||
|
|
|
@ -169,6 +169,9 @@ export interface Config {
|
|||
log_level: string;
|
||||
log_path: string;
|
||||
base_url: string;
|
||||
version: string;
|
||||
commit: string;
|
||||
date: string;
|
||||
}
|
||||
|
||||
export interface Release {
|
||||
|
|
|
@ -80,6 +80,22 @@ function ApplicationSettings() {
|
|||
</div>
|
||||
|
||||
<div className="pt-6 pb-6 divide-y divide-gray-200 dark:divide-gray-700">
|
||||
<div className="px-4 py-5 sm:p-0">
|
||||
<dl className="sm:divide-y divide-gray-200 dark:divide-gray-700">
|
||||
<div className="py-4 sm:py-5 sm:grid sm:grid-cols-4 sm:gap-4 sm:px-6">
|
||||
<dt className="font-medium text-gray-500 dark:text-white">Version:</dt>
|
||||
<dd className="mt-1 font-semibold text-gray-900 dark:text-white sm:mt-0 sm:col-span-2">{data?.version}</dd>
|
||||
</div>
|
||||
<div className="py-4 sm:py-5 sm:grid sm:grid-cols-4 sm:gap-4 sm:px-6 dark:bg-gray-700">
|
||||
<dt className="font-medium text-gray-500 dark:text-white">Commit:</dt>
|
||||
<dd className="mt-1 font-semibold text-gray-900 dark:text-white sm:mt-0 sm:col-span-2">{data?.commit}</dd>
|
||||
</div>
|
||||
<div className="py-4 sm:py-5 sm:grid sm:grid-cols-4 sm:gap-4 sm:px-6">
|
||||
<dt className="font-medium text-gray-500 dark:text-white">Date:</dt>
|
||||
<dd className="mt-1 font-semibold text-gray-900 dark:text-white sm:mt-0 sm:col-span-2">{data?.date}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</div>
|
||||
<div className="px-4 sm:px-6">
|
||||
<ul className="mt-2 divide-y divide-gray-200">
|
||||
<Switch.Group as="li" className="py-4 flex items-center justify-between">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue