Skip to content

Instantly share code, notes, and snippets.

@Ferada
Forked from waynr/cgconfig.conf
Created June 11, 2020 17:48
Show Gist options
  • Save Ferada/19a624abc4605d3fa3b3ef4d6438147a to your computer and use it in GitHub Desktop.
Save Ferada/19a624abc4605d3fa3b3ef4d6438147a to your computer and use it in GitHub Desktop.
group gotools {
perm {
admin {
uid = UID;
gid = UID;
}
task {
uid = UID;
gid = UID;
}
}
cpu {
cpu.shares = 256;
}
memory {
# limit to 6GB
memory.limit_in_bytes = 6442450944;
}
}
~
#!/bin/bash
cgexec \
-g memory,cpu:gotools \
$GOPATH/bin/gopls.real "$@"
$ sudo apt install cgroup-tools
$ mv cgconfig.conf /etc/cgconfig.conf
$ sed -i -e 's|UID|$(id -u)|' /etc/cgconfig.conf
$ sudo cgconfigparser -l /etc/cgconfig.conf
$ mv $GOPATH/bin/gopls $GOPATH/bin/gopls.real
$ ln -sf /path/to/gopls.bash $GOPATH/bin/gopls
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment