DEVELOPMENT ENVIRONMENT

~liljamo/deck-builder

dcf9261127d7f89918f0607f6f04e274fac806af — Jonni Liljamo 1 year, 10 months ago 0ad6606
feat(sdbapi): set ulimits
1 files changed, 16 insertions(+), 0 deletions(-)

M sdbapi/main.go
M sdbapi/main.go => sdbapi/main.go +16 -0
@@ 14,11 14,17 @@ import (
	"api/middlewares"
	"log"
	"os"
	"syscall"

	"github.com/gin-gonic/gin"
)

func main() {
	err := setUlimits()
	if err != nil {
		log.Fatal("failed to set Ulimits")
	}

	dbConnectionString := os.Getenv("GORM_DB_STRING")

	db.Connect(dbConnectionString)


@@ 57,3 63,13 @@ func createRouter() *gin.Engine {
	}
	return router
}

// Set NOFILE limit to max, to allow more concurrent websocket connections
func setUlimits() error {
	var rlimit syscall.Rlimit
	if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rlimit); err != nil {
		return err
	}
	rlimit.Cur = rlimit.Max
	return syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rlimit)
}