Skip to content

omnibus-ctl tail : avoid large process tree to be kept in memory for no reason.

Currently omnibus-ctl tail will generate this process tree (because of waiting for shell and using shell pipes) :

      ├─gitlab-ctl,366283 /opt/gitlab/bin/gitlab-ctl tail
      │   └─omnibus-ctl,366285 /opt/gitlab/embedded/bin/omnibus-ctl gitlab /opt/gitlab/embedded/service/omnibus-ctl* tail
      │       └─sh,366298 -c find -L /var/log/gitlab -type f -not -path '*/sasl/*' | grep -E -v '(config|lock|@|gzip|tgz|gz)' | xargs tail --follow=name --retry
      │           └─xargs,366301 tail --follow=name --retry
      │               └─tail,366304 --follow=name --retry /var/log/gitlab/logrotate/current /var/log/gitlab/logrotate/state /var/log/gitlab/gitlab-workhorse/current /var/log/gitlab/gitlab-workhorse/state...

This is simpler to compute the logfiles first, then invoke tail on them, and using exec instead of system. This will fold a 4-process-chain into 1 process.

Note: the original code is not white-space safe nor does it gracefully empty logfile list, the patch does not propose to change that.

Merge request reports