I use Atom and for golang development I did the following:
- Created a new cgroup limited by CPU time:
/etc/cgconfig.conf
group groupname {
perm {
# who can manage limits
admin {
uid = 0;
gid = 0;
}
# who can add tasks to this group
task {
uid = 1000;
gid = 1000;
}
}
# create this group in cpu and memory controllers
cpu { }
memory { }
}
group groupname/foo {
cpu {
cpu.cfs_period_us = 1000000;
cpu.cfs_quota_ns = 500000;
}
}
- Updated
toolbox to pass --cgroup-parent sandbox to new toolbox container
- Created a new dedicated toolbox container -
go-1.12 and installed golang from F30 repos
- Created a script to generate wrappers for golang binaries:
~/go/wrappers-bin/create-wrappers.sh
#!/bin/bash
container_name="go-1.12"
prefix="flatpak-spawn --host podman exec -u 1000 -i"
gobin="/home/vrutkovs/go/bin"
bins=$(find $gobin -executable -type f)
for file in ${bins[@]} go gofmt; do
echo -e "#!/bin/sh\n\n${prefix} ${container_name} $(basename $file) \$@" > ./$(basename $file)
done
chmod 0755 ./*
- Generated wrappers for installed go binaries
- Updated flatpaked Atom’s PATH to have a path for wrapper binaries first:
flatpak --user override io.atom.Atom --env=PATH=/var/home/vrutkovs/go/wrappers-bin:/app/bin:/usr/bin:/var/home/vrutkovs/go/bin
Now whenever Atom’s go-plus invokes go or any of its binaries these are in fact running in CPU limited container.
I didn’t try this method for VSCode yet though