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