Datagerry 2.2.0 - problem with stop service

Hello,
I use datagerry from zip package. My operating system is Ubuntu 22.04.
Datagerry starts normal nad works correctly after start machine.

Works after start

root@server:~# systemctl status datagerry
● datagerry.service - DATAGERRY - Enterprise grade OpenSource CMDB
Loaded: loaded (/etc/systemd/system/datagerry.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2024-07-02 11:27:23 CEST; 1 day 1h ago
Main PID: 1537 (datagerry)
Tasks: 37 (limit: 4556)
Memory: 1.1G
CPU: 10min 43.745s
CGroup: /system.slice/datagerry.service
├─1537 /usr/bin/datagerry -c /etc/datagerry/cmdb.conf -s
├─1546 /usr/bin/datagerry -c /etc/datagerry/cmdb.conf -s
├─1554 /usr/bin/datagerry -c /etc/datagerry/cmdb.conf -s
├─1559 /usr/bin/datagerry -c /etc/datagerry/cmdb.conf -s
├─1563 /usr/bin/datagerry -c /etc/datagerry/cmdb.conf -s
├─1564 /usr/bin/datagerry -c /etc/datagerry/cmdb.conf -s
├─1565 /usr/bin/datagerry -c /etc/datagerry/cmdb.conf -s
├─1566 /usr/bin/datagerry -c /etc/datagerry/cmdb.conf -s
├─1567 /usr/bin/datagerry -c /etc/datagerry/cmdb.conf -s
└─1568 /usr/bin/datagerry -c /etc/datagerry/cmdb.conf -s

Jul 03 12:53:44 server.local datagerry[1564]: File “cmdb/interface/error_handlers.py”, line 78, in bad_request
Jul 03 12:53:44 server.local datagerry[1564]: File “cmdb/interface/error_handlers.py”, line 64, in make_error
Jul 03 12:53:44 server.local datagerry[1564]: File “flask/json/init.py”, line 170, in jsonify
Jul 03 12:53:44 server.local datagerry[1564]: File “flask/json/provider.py”, line 214, in response
Jul 03 12:53:44 server.local datagerry[1564]: File “flask/json/provider.py”, line 179, in dumps
Jul 03 12:53:44 server.local datagerry[1564]: File “json/init.py”, line 234, in dumps
Jul 03 12:53:44 server.local datagerry[1564]: File “json/encoder.py”, line 199, in encode
Jul 03 12:53:44 server.local datagerry[1564]: File “json/encoder.py”, line 257, in iterencode
Jul 03 12:53:44 server.local datagerry[1564]: File “flask/json/provider.py”, line 121, in _default
Jul 03 12:53:44 server.local datagerry[1564]: TypeError: Object of type ManagerUpdateError is not JSON serializable

but when i try to stop service, it crashes

Try to stop datagerry

root@server:~# systemctl stop datagerry
root@server:~# systemctl status datagerry
× datagerry.service - DATAGERRY - Enterprise grade OpenSource CMDB
Loaded: loaded (/etc/systemd/system/datagerry.service; enabled; vendor preset: enabled)
Active: failed (Result: timeout) since Wed 2024-07-03 13:12:58 CEST; 36s ago
Process: 1537 ExecStart=/usr/bin/datagerry -c /etc/datagerry/cmdb.conf -s (code=killed, signal=KILL)
Main PID: 1537 (code=killed, signal=KILL)
Tasks: 36 (limit: 4556)
Memory: 1.1G
CPU: 10min 44.168s
CGroup: /system.slice/datagerry.service
├─1546 /usr/bin/datagerry -c /etc/datagerry/cmdb.conf -s
├─1554 /usr/bin/datagerry -c /etc/datagerry/cmdb.conf -s
├─1559 /usr/bin/datagerry -c /etc/datagerry/cmdb.conf -s
├─1563 /usr/bin/datagerry -c /etc/datagerry/cmdb.conf -s
├─1564 /usr/bin/datagerry -c /etc/datagerry/cmdb.conf -s
├─1565 /usr/bin/datagerry -c /etc/datagerry/cmdb.conf -s
├─1566 /usr/bin/datagerry -c /etc/datagerry/cmdb.conf -s
├─1567 /usr/bin/datagerry -c /etc/datagerry/cmdb.conf -s
└─1568 /usr/bin/datagerry -c /etc/datagerry/cmdb.conf -s

Jul 03 13:12:58 server.local systemd[1]: datagerry.service: Unit process 1554 (datagerry) remains running after unit stopped.
Jul 03 13:12:58 server.local systemd[1]: datagerry.service: Unit process 1559 (datagerry) remains running after unit stopped.
Jul 03 13:12:58 server.local systemd[1]: datagerry.service: Unit process 1563 (datagerry) remains running after unit stopped.
Jul 03 13:12:58 server.local systemd[1]: datagerry.service: Unit process 1564 (datagerry) remains running after unit stopped.
Jul 03 13:12:58 server.local systemd[1]: datagerry.service: Unit process 1565 (datagerry) remains running after unit stopped.
Jul 03 13:12:58 server.local systemd[1]: datagerry.service: Unit process 1566 (datagerry) remains running after unit stopped.
Jul 03 13:12:58 server.local systemd[1]: datagerry.service: Unit process 1567 (datagerry) remains running after unit stopped.
Jul 03 13:12:58 server.local systemd[1]: datagerry.service: Unit process 1568 (datagerry) remains running after unit stopped.
Jul 03 13:12:58 server.local systemd[1]: Stopped DATAGERRY - Enterprise grade OpenSource CMDB.
Jul 03 13:12:58 server.local systemd[1]: datagerry.service: Consumed 10min 44.056s CPU time.
root@server:~# ps aux | grep datagerry
datager+ 1546 0.0 2.1 473252 84612 ? Sl Jul02 0:01 /usr/bin/datagerry -c /etc/datagerry/cmdb.conf -s
datager+ 1554 0.0 1.2 781788 48916 ? Sl Jul02 0:28 /usr/bin/datagerry -c /etc/datagerry/cmdb.conf -s
datager+ 1559 0.0 2.5 437304 102112 ? Sl Jul02 0:26 /usr/bin/datagerry -c /etc/datagerry/cmdb.conf -s
datager+ 1563 0.0 2.4 437560 97296 ? S Jul02 0:12 /usr/bin/datagerry -c /etc/datagerry/cmdb.conf -s
datager+ 1564 0.1 4.5 516812 181404 ? Sl Jul02 1:52 /usr/bin/datagerry -c /etc/datagerry/cmdb.conf -s
datager+ 1565 0.1 4.9 534332 199116 ? Sl Jul02 1:49 /usr/bin/datagerry -c /etc/datagerry/cmdb.conf -s
datager+ 1566 0.1 4.9 534248 198860 ? Sl Jul02 1:54 /usr/bin/datagerry -c /etc/datagerry/cmdb.conf -s
datager+ 1567 0.1 5.0 535188 200860 ? Sl Jul02 2:01 /usr/bin/datagerry -c /etc/datagerry/cmdb.conf -s
datager+ 1568 0.1 5.0 536056 200824 ? Sl Jul02 1:54 /usr/bin/datagerry -c /etc/datagerry/cmdb.conf -s
root 195550 0.0 0.0 6612 2324 pts/1 S+ 13:14 0:00 grep --color=auto datagerry

and datagerry processes still work

Processes works after stop service

root@server:~# pgrep datagerry
1546
1554
1559
1563
1564
1565
1566
1567
1568

and next for normal start i have to first kill all processes or restart machine

Summary

root@server:~# pkill -9 datagerry
root@server:~# pgrep datagerry
root@server:~# systemctl start datagerry
root@server:~# systemctl status datagerry
● datagerry.service - DATAGERRY - Enterprise grade OpenSource CMDB
Loaded: loaded (/etc/systemd/system/datagerry.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2024-07-03 13:15:37 CEST; 2s ago
Main PID: 195715 (datagerry)
Tasks: 2 (limit: 4556)
Memory: 281.2M
CPU: 2.259s
CGroup: /system.slice/datagerry.service
├─195715 /usr/bin/datagerry -c /etc/datagerry/cmdb.conf -s
└─195717 /usr/bin/datagerry -c /etc/datagerry/cmdb.conf -s

Jul 03 13:15:37 server.local systemd[1]: Started DATAGERRY - Enterprise grade OpenSource CMDB.

Could you check it

Hi @marcinw ,
thanks for the input, we will have a look at this.

BR Adnan

Hi,

This is not new. It was present on v 2.1.0. One must kill the processes afterwards.

Hey @sink1

Will be it fixed?

No idea. I don’t work for them :slight_smile:

Hey @sink1,

I looked wrong :wink: sorry

Hey @sink1

I looked wrong, sorry :wink:

1 Like

By the way, a reason this might not work is because the supplied unit file tries to kill the processes with this:

[Service]
User=datagerry
Group=datagerry
Type=simple
ExecStart=/usr/bin/datagerry -c /etc/datagerry/cmdb.conf -s -d
KillMode=process
Restart=on-failure

KillMode=process is unrealiable, and as such the processes are not killed. Even the makers of systemctl discourage this:

" Note that it is not recommended to set KillMode= to process or even none , as this allows processes to escape the service manager’s lifecycle and resource management, and to remain running even while their service is considered stopped and is assumed to not consume any resources." Source: systemd.kill

Becom can programme a stop parameter into their binary that gracefully terminates the processes. I hope that this is on their roadmap.

In the meantime, I did this in /usr/lib/systemd/system/datagerry.service

[Service]
User=datagerry
Group=datagerry
Type=simple
ExecStart=/usr/bin/datagerry -c /etc/datagerry/cmdb.conf -s -d
ExecStop=pkill -U datagerry
#KillMode=process
Restart=on-failure

Hi @sink1,
thanks for this input, we will have a look at this issue.

BR Adnan