Last active
June 11, 2020 17:48
-
-
Save waynr/a53b3f4ab3a80f76bea99c5ae705803d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} | |
~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cgexec \ | |
-g memory,cpu:gotools \ | |
$GOPATH/bin/gopls.real "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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 |
Also worth noting, to get the most mileage out of this you will probably have to configure your editor to pass the --remote=auto
option to gopls.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not totally clear to me if
/etc/cgconfig.conf
is automatically parsed at boot. Also, obviously, if you are running a different distribution you will have to change the install step.