example

command
v0.0.0-...-62522d3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 28, 2024 License: MIT Imports: 17 Imported by: 0

README

Example

[!IMPORTANT]

This is an example and is NOT covered by semver compatibility guarantees.

If PORT env variable is specified and is a valid port, a simple http server is started on that port, listening on all available interfaces. Alternatively, -listen flag can be used to specify listening address. If both are not specified, then container simply prints GOMAXPROCS and GOMEMLIMIT values and some runtime/platform data to stdout and exits.

Docker

Example docker images are only provided for limited number of platforms/architectures.

As examples are not covered by semver compatibility guarantees, semver tagged images are not provided. However, images are tagged with both short and full commit hashes to test a specific commit. latest tag corresponds to HEAD of the default branch.

SLSA build level 3 provenance is attached to the images. This project also provides GitHub native provenance for images, though only at SLSA build level 2, due to isolation requirements.

slsa-level3-badge

docker run --rm --cpus=1.5 --memory=250M ghcr.io/tprasadtp/go-autotune
Docker (Linux)

linux-stdout

Docker (Windows)

[!IMPORTANT]

Example docker images are only provided for Server 2019, Server 2022 and Server 2025 because of Windows container version compatibility.

windows-stdout

windows-server

Systemd

  • Clone this repository.

    git clone --depth=1 https://github.com/tprasadtp/go-autotune
    
  • Checkout the repository.

    cd go-autotune
    
  • Build the example binary and install it to ~/.local/bin as "go-autotune".

    go build -trimpath \
      -ldflags='-w -s' \
      -tags=osusergo,netgo \
      -o ~/.local/bin/go-autotune \
      github.com/tprasadtp/go-autotune/example
    
  • Verify that CPU and memory controllers are available for user level units. If output does not contain strings cpu and memory, CPU controllers are not available for user level units. Install the binary to a root accessible location (like /usr/local/bin) and run the systemd-run commands without the --user flag.

    systemctl show user@$(id -u).service -P DelegateControllers
    
  • Run the example binary as a transient unit with with resource limits applied.

    systemd-run -Pq --user -p "CPUQuota=150%" -p MemoryHigh=250M -p MemoryMax=300M go-autotune
    

    linux-systemd

Documentation

Overview

Example CLI which can show GOMAXPROCS and GOMEMLIMIT values.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL