Simple tool to run command with limited resource. Only works on linux for now.
Your need libcgroup to compile go-cgroup. Install it with your package manager:
On debian:
sudo apt-get install -y libcgroup-devOn fedora:
sudo yum install -y libcgroup-develInstall this project:
go get github.com/inoc603/go-limitMake sure you have root privilege and $GOPATH/bin is in your PATH
go-limit --cpu CPU_USAGE_PERCENTAGE --memory MEMORY_LIMIT YOUR_COMMANDCPU_USAGE_PERCENTAGE is an interger between 1 and 100
MEMORY_LIMIT is the memory limit in bytes, the following formats are allowed:
- 512
- 128k 128k
- 128m 128M
- 128g 128G
# limit cpu usage to 50%
go-limit --cpu 50 example/cpu.py
# limit memory usage to 512MB
go-limit --memory 512M example/mem.py- Handle keyboard interruption signal