Hi FB Experts , FB friends, and everyone! I have ...
# fluent-bit
e
Hi FB Experts , FB friends, and everyone! I have a question how to properly and gently and fast stop the systemd service on
CentOS Linux 8
we have configured for
fluent-bit 4.0.2 ..
Currently we have this setting -- see below, which has many default values set (see manpage for systemd), especially:
DefaultTimeoutStopSec=90
This directive/property causes that command
systemctl stop mon-logagent
... will start to stop fluent-bit and if it will not be finished during 90s then SIGKILL signal is sent. Our requirement is to reduce the stopping time to minimum ... let's say
15s
. Ideally try the sequence of signals like is described below: https://github.com/systemd/systemd/issues/13284
SIGSTOP -- wait few sec.  -- SIGTERM -- wait few sec. -- SIGKILL
------------ Is there some recommended way to do it? ------------------ Here is our service's config file: # /etc/systemd/system/mon-logagent.service
Copy code
[Unit]
Description=mon logagent
After=local-fs.target network-online.target network.target rsyslog.service sshd.service

[Service]
Type=simple
LimitNOFILE=65536
ExecStartPre=/var/lib/mon/scripts/mon-logagent-pre.sh
ExecStartPost=/var/lib/mon/scripts/mon-logagent-post-start.sh
EnvironmentFile=-/etc/sysconfig/mon-fa-logagent
ExecStart=/usr/local/bin/mon/fluent-bit -c /usr/local/etc/mon-fluent-bit/fluent-bit.yaml
RestartSec=60
Restart=always
MemoryMax=6G
MemoryLimit=6G
MemorySwapMax=4G
ExecReload=/bin/kill -s SIGHUP $MAINPID

[Install]
WantedBy=multi-user.target
p
Is it not stopping? I'm not sure what the issue is? It should exit pretty quickly There are various options to configure on the fluent bit side you can see in the docs.
e
@Pat It does stopping but not in time range we want .. it means we want to stop service independent on how box is loaded till 15s. I did some research and looks like the change from default value 'control-group' to 'mixed' for directive
KillMode
If you ask AI .. then you get response like ..
Copy code
If your app's shutdown logic is well written .. KillMode=mixed can be much cleaner and faster than mass-signaling (KillMode=control-group)
So is your 🙂 code designed for KillMode=mixed or for any other Kill mode is better recommend? Of course we want to have guarantee that there will be no files corruption (FB database offset/position files) and minimal records loss.
As I mentioned above ... Our requirement is to reduce the stopping time to minimum ... let's say
15s
So far it looks like that I I send whatever signal to main fluent-bit process 1st (KillMode=mixed), this will handle stopping all childs, threads,.. a bit faster (maybe 20%) then if I let it do by cgroup (KillMode=control-group))
Probably it depends on C libraries in the source code .. , but I am not expert on that. Thank you for any guidance!!