Skip to content

Simple tool to run command with limited resource

License

Notifications You must be signed in to change notification settings

inoc603/go-limit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-limit

Simple tool to run command with limited resource. Only works on linux for now.

Install

Your need libcgroup to compile go-cgroup. Install it with your package manager:

On debian:

sudo apt-get install -y libcgroup-dev

On fedora:

sudo yum install -y libcgroup-devel

Install this project:

go get github.com/inoc603/go-limit

Usage

Make sure you have root privilege and $GOPATH/bin is in your PATH

go-limit --cpu CPU_USAGE_PERCENTAGE --memory MEMORY_LIMIT YOUR_COMMAND

CPU_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

Example

# limit cpu usage to 50%
go-limit --cpu 50 example/cpu.py
# limit memory usage to 512MB
go-limit --memory 512M example/mem.py

TODO

  • Handle keyboard interruption signal

About

Simple tool to run command with limited resource

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published