3 ms·
Well, the flock command mentioned in the article will also work, but you might have to deal with having a bit more boilerplate around everything. The moreutils
by kbenson 5y ago
Well, the flock command mentioned in the article will also work, but you might have to deal with having a bit more boilerplate around everything. The moreutils things are pretty small, some are just implemented as small perl scripts even.
If you're writing the program, it's fairly easy to do yourself in it with Flock or Fcntl (you can usually just get an exclusive lock in the absolute path to the running executable/script.
That said, quite a few of those moreutils items are useful in their own right (e.g. ts to prefix timestamps to each line of output is something so simple but so useful for logging output, chronic to silence stdout unless exit error is also very useful for cron, etc).
- eurasiantiger 5y agoBut doesn’t flock also require installing a utils package? The docker people, recently being forced to choose a life of mass migration, would greatly appreciate tools which do not introduce additional overhead to be carried across the whaling sea to the kubed podlands.
- kbenson 5y ago$ rpm -qi moreutils | grep Size Size : 194354 $ rpm -qi util-linux | grep Size Size : 11565734 So, < 200k compared to > 11MB based on compressed package, or if you want more specific counts for moreutils: $ rpm -ql moreutils | grep -v build-id | xargs du -hc 4.0K /usr/bin/chronic 4.0K /usr/bin/combine 20K /usr/bin/errno 24K /usr/bin/ifdata 16K /usr/bin/ifne 20K /usr/bin/isutf8 16K /usr/bin/lckdo 16K /usr/bin/mispipe 16K /usr/bin/pee 20K /usr/bin/sponge 8.0K /usr/bin/ts 8.0K /usr/bin/vidir 4.0K /usr/bin/vipe 4.0K /usr/bin/zrun 24K /usr/share/doc/moreutils 4.0K /usr/share/man/man1/chronic.1.gz ... 4.0K /usr/share/man/man1/zrun.1.gz 260K total The very small utils are actually perl scripts so there's a few dependencies it may pull in there (especially if there's no Perl in the container already, but this is for CentOS so people might be using different base containers. But honestly, a package made that excludes the perl portions would be ideal for containers. From what I can tell, there's no other libraries used except glibc, and then you get most of those implemented in ~20k or less each. $ rpm -ql moreutils | grep bin/ | xargs -n1 ldd | cut -d'(' -f1 | sort | uniq /lib64/ld-linux-x86-64.so.2 libc.so.6 => /lib64/libc.so.6 linux-vdso.so.1 not a dynamic executable If the perl was split into separate packages (CentOS already ships moreutils and moreutils-parallel to split that out), that would be ideal for containers for the portions that are binaries, IMO.