Skip to content

Commit

Permalink
chore(deps): Bumping deps and tuning pprof config
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Boutour <[email protected]>
  • Loading branch information
ViBiOh committed May 4, 2024
1 parent 66df089 commit 20da0a1
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 15 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ Fibr provides [OpenGraph metadatas](https://ogp.me) to have nice preview of link

You can start `fibr` with no user, with the `-noAuth` option. Although available, I don't recommend using it in public Internet. Anybody has access to the _root folder_ for viewing, uploading, deleting or sharing content with anybody.

Users are set with the `-authUsers` option and are in the form `[id]:[login]:[argon encoded has]`.
Users are set with the `-authUsers` option and are in the form `[id]:[login]:[argon encoded hash]`.

- `id` is used to add profile to your user
- `login` is the user for Basic Auth prompt
Expand Down Expand Up @@ -260,6 +260,7 @@ Usage of fibr:
--pathPrefix string Root Path Prefix ${FIBR_PATH_PREFIX}
--port uint [server] Listen port (0 to disable) ${FIBR_PORT} (default 1080)
--pprofAgent string [pprof] URL of the Datadog Trace Agent (e.g. http://datadog.observability:8126) ${FIBR_PPROF_AGENT}
--pprofPort int [pprof] Port of the HTTP server (0 to disable) ${FIBR_PPROF_PORT} (default 0)
--publicURL string Public URL ${FIBR_PUBLIC_URL} (default "http://localhost:1080")
--readTimeout duration [server] Read Timeout ${FIBR_READ_TIMEOUT} (default 2m0s)
--redisAddress string slice [redis] Redis Address host:port (blank to disable) ${FIBR_REDIS_ADDRESS}, as a string slice, environment variable separated by ","
Expand Down
4 changes: 4 additions & 0 deletions cmd/fibr/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ func newClient(ctx context.Context, config configuration) (client, error) {
return output, nil
}

func (c client) Start() {
go c.pprof.Start(c.health.DoneCtx())
}

func (c client) Close(ctx context.Context) {
c.amqp.Close()
c.redis.Close()
Expand Down
9 changes: 1 addition & 8 deletions cmd/fibr/fibr.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ package main
import (
"context"
"embed"
"fmt"
"log/slog"
"net/http"
"os"

_ "net/http/pprof"
Expand Down Expand Up @@ -41,16 +39,13 @@ func main() {
config := newConfig()
alcotest.DoAndExit(config.alcotest)

go func() {
fmt.Println(http.ListenAndServe("localhost:9999", http.DefaultServeMux))
}()

ctx := context.Background()

clients, err := newClient(ctx, config)
logger.FatalfOnErr(ctx, err, "clients")

defer clients.Close(ctx)
go clients.Start()

adapters, err := newAdapters(config, clients)
logger.FatalfOnErr(ctx, err, "adapters")
Expand All @@ -68,8 +63,6 @@ func main() {
stopOnEnd.Start(endCtx)
defer stopOnEnd.GracefulWait()

go clients.pprof.Start(clients.health.DoneCtx())

go adapters.eventBus.Start(endCtx, adapters.storage, []provider.Renamer{services.thumbnail.Rename, services.metadata.Rename}, services.share.EventConsumer, services.thumbnail.EventConsumer, services.metadata.EventConsumer, services.webhook.EventConsumer)

appServer := server.New(config.appServer)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/ViBiOh/auth/v2 v2.18.2
github.com/ViBiOh/exas v0.7.1
github.com/ViBiOh/flags v1.5.0
github.com/ViBiOh/httputils/v4 v4.75.2
github.com/ViBiOh/httputils/v4 v4.75.3
github.com/ViBiOh/vith v0.6.0
github.com/rabbitmq/amqp091-go v1.9.0
github.com/redis/go-redis/v9 v9.5.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ github.com/ViBiOh/exas v0.7.1 h1:nzh6E1668OFRgoTIJZJa1RybCW64Gd918qi0Z+0Q4WA=
github.com/ViBiOh/exas v0.7.1/go.mod h1:MvIWQZXpWgg45Vsde9bMV48Kb0J8frya8vimmrkQ04E=
github.com/ViBiOh/flags v1.5.0 h1:nwuFS8tAwtV6rTPpv2pCB+r12WjZYLjluW7yT+SeVpQ=
github.com/ViBiOh/flags v1.5.0/go.mod h1:39UMuTnKsIp6walgD8dK99KRCb4DJt9vPtbWehHh1T0=
github.com/ViBiOh/httputils/v4 v4.75.2 h1:U+768KbZA4TS1KDfic4gZaeLRhXP3h9/cYrqI3hzZjc=
github.com/ViBiOh/httputils/v4 v4.75.2/go.mod h1:hjrxCv58B8RFGgGNjIOBXqnzoYL7De2IjC2AIMsRKWU=
github.com/ViBiOh/httputils/v4 v4.75.3 h1:+weNBuOx5ApBZXZ/Ku5cVwfedThrvBh7ZpzV5lTDeHQ=
github.com/ViBiOh/httputils/v4 v4.75.3/go.mod h1:hjrxCv58B8RFGgGNjIOBXqnzoYL7De2IjC2AIMsRKWU=
github.com/ViBiOh/vith v0.6.0 h1:bdLmwgqUEWi3ivShtAhtM9gOZlWQzvZi2Z5b0BRSB1U=
github.com/ViBiOh/vith v0.6.0/go.mod h1:eRqtDU2uB8g85vll4spbnCV93DHyHNAYwXCMIBH1GuQ=
github.com/bsm/ginkgo/v2 v2.7.0/go.mod h1:AiKlXPm7ItEHNc/2+OkrNG4E0ITzojb9/xWzvQ9XZ9w=
Expand Down
2 changes: 0 additions & 2 deletions infra/web.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,3 @@ spec:
allowPrivilegeEscalation: false
autoscaling:
enabled: false
pprof:
enabled: true
4 changes: 3 additions & 1 deletion pkg/crud/search.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package crud

import (
"fmt"
"log/slog"
"net/http"

absto "github.com/ViBiOh/absto/pkg/model"
Expand All @@ -16,7 +18,7 @@ func (s Service) search(r *http.Request, request provider.Request, item absto.It

metadatas, err := s.metadata.GetAllMetadataFor(ctx, files...)
if err != nil {
listLogger(item.Pathname).ErrorContext(ctx, "list metadatas: %s", err)
listLogger(item.Pathname).LogAttrs(ctx, slog.LevelError, fmt.Sprintf("list metadatas: %s", err))
}

items := make([]provider.RenderItem, len(files))
Expand Down

0 comments on commit 20da0a1

Please sign in to comment.