func main()

in cmd/aws-lambda-rie/main.go [33:88]


func main() {
	// More frequent GC reduces the tail latencies, equivalent to export GOGC=33
	debug.SetGCPercent(33)

	opts, args := getCLIArgs()

	logLevel := "info"

	// If you specify an option by using a parameter on the CLI command line, it overrides any value from either the corresponding environment variable.
	//
	// https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-envvars.html
	if opts.LogLevel != "" {
		logLevel = opts.LogLevel
	} else if envLogLevel, envLogLevelSet := os.LookupEnv("LOG_LEVEL"); envLogLevelSet {
		logLevel = envLogLevel
	}

	rapidcore.SetLogLevel(logLevel)

	if opts.RuntimeAPIAddress != "" {
		_, _, err := net.SplitHostPort(opts.RuntimeAPIAddress)

		if err != nil {
			log.WithError(err).Fatalf("The command line value for \"--runtime-api-address\" is not a valid network address %q.", opts.RuntimeAPIAddress)
		}
	}

	_, _, err := net.SplitHostPort(opts.RuntimeInterfaceEmulatorAddress)

	if err != nil {
		log.WithError(err).Fatalf("The command line value for \"--runtime-interface-emulator-address\" is not a valid network address %q.", opts.RuntimeInterfaceEmulatorAddress)
	}

	bootstrap, handler := getBootstrap(args, opts)
	sandbox := rapidcore.
		NewSandboxBuilder().
		AddShutdownFunc(context.CancelFunc(func() { os.Exit(0) })).
		SetExtensionsFlag(true).
		SetInitCachingFlag(opts.InitCachingEnabled)

	if len(handler) > 0 {
		sandbox.SetHandler(handler)
	}

	if opts.RuntimeAPIAddress != "" {
		sandbox.SetRuntimeAPIAddress(opts.RuntimeAPIAddress)
	}

	sandboxContext, internalStateFn := sandbox.Create()
	// Since we have not specified a custom interop server for standalone, we can
	// directly reference the default interop server, which is a concrete type
	sandbox.DefaultInteropServer().SetSandboxContext(sandboxContext)
	sandbox.DefaultInteropServer().SetInternalStateGetter(internalStateFn)

	startHTTPServer(opts.RuntimeInterfaceEmulatorAddress, sandbox, bootstrap)
}