diff options
author | 2024-06-13 19:02:48 +0200 | |
---|---|---|
committer | 2024-06-13 19:02:48 +0200 | |
commit | 3c86bd890c54ac6f54f07a5d7c1d3f8d5e399641 (patch) | |
tree | 88be0c6f2be82b4e5f0e7773bd6f1c55b04a99a1 | |
parent | [docs] Add optional instructions for replicating SQLite for disaster recovery... (diff) | |
download | gotosocial-3c86bd890c54ac6f54f07a5d7c1d3f8d5e399641.tar.xz |
[chore] Silence memlimit package (#3002)
The memlimit package started to log any error returned by automemlimit.
This updates our implementation to call SetGoMemLimitWithOpts() instead
which uses the same defaults as automemlimit except for being
initialised with a noop logger.
We check the returned error for a particular substring, as when cgroups
isn't available even when running on a Linux system that's not a
problem. If it's anything but that error, we log it at the warning
level so that admins can still diagnose other cgroup related issues.
Fixes #2983
Co-authored-by: tobi <31960611+tsmethurst@users.noreply.github.com>
-rw-r--r-- | cmd/gotosocial/action/server/server.go | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/cmd/gotosocial/action/server/server.go b/cmd/gotosocial/action/server/server.go index 24b3771df..14db67795 100644 --- a/cmd/gotosocial/action/server/server.go +++ b/cmd/gotosocial/action/server/server.go @@ -24,9 +24,11 @@ import ( "net/http" "os" "os/signal" + "strings" "syscall" "time" + "github.com/KimMachineGun/automemlimit/memlimit" "github.com/gin-gonic/gin" "github.com/superseriousbusiness/gotosocial/cmd/gotosocial/action" "github.com/superseriousbusiness/gotosocial/internal/api" @@ -60,9 +62,6 @@ import ( "github.com/superseriousbusiness/gotosocial/internal/transport" "github.com/superseriousbusiness/gotosocial/internal/typeutils" "github.com/superseriousbusiness/gotosocial/internal/web" - - // Inherit memory limit if set from cgroup - _ "github.com/KimMachineGun/automemlimit" ) // Start creates and starts a gotosocial server @@ -71,6 +70,12 @@ var Start action.GTSAction = func(ctx context.Context) error { log.Warnf(ctx, "could not set CPU limits from cgroup: %s", err) } + if _, err := memlimit.SetGoMemLimitWithOpts(); err != nil { + if !strings.Contains(err.Error(), "cgroup mountpoint does not exist") { + log.Warnf(ctx, "could not set Memory limits from cgroup: %s", err) + } + } + var ( // Define necessary core variables // before anything so we can prepare |