mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-11-22 03:36:39 +00:00
[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>
This commit is contained in:
parent
38cd889f7b
commit
3c86bd890c
|
@ -24,9 +24,11 @@
|
|||
"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 @@
|
|||
"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 @@
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue