Problem: UCS@school ID connector fails to start if old pid-file exists

Problem

If the service cannot be started by the ID connector, it may be due to unprocessed pid file blocking the service. Among other things, this can be caused by a power failure in the system.

The Bug 54640 causes this misbehavior.

You will get this output if you check the container log with:
univention-app logs ucsschool-id-connector

This init-script assumes that old pid-files are removed and fails to start once a remnant exists. This may be tha case on unclean shutdown.

/etc/init.d # ./ucsschool-id-connector start
 * Starting UCS@school ID Connector ...
Traceback (most recent call last):
  File "/ucsschool-id-connector/src/queue_management", line 170, in <module>
    _start()
  File "/ucsschool-id-connector/src/queue_management", line 151, in _start
    service.start()
  File "/usr/lib/python3.8/site-packages/service/__init__.py", line 461, in start
    raise ValueError('Daemon is already running at PID %d.' % pid)
ValueError: Daemon is already running at PID 146.                                                                                                                                                                                                       [ !! ]
 * ERROR: ucsschool-id-connector failed to start
/etc/init.d # cat /tmp/IDConnectorService.pid
146
/etc/init.d # 
/etc/init.d # pgrep IDConnectorService
/etc/init.d # rm /tmp/IDConnectorService.pid 
/etc/init.d # ./ucsschool-id-connector start
 * Starting UCS@school ID Connector ...
Started IDConnectorService daemon.                                                                                                                                                                                                                      [ ok ]
/etc/init.d # ./ucsschool-id-connector status
 * status: started

Solution

Connect into the container and check if an old PID File exist.

univention-app shell ucsschool-id-connector

/ucsschool-id-connector # ls -lah  /tmp/
drwxrwxrwx    1 root     root        4.0K Dec 10 16:36 .
drwxr-xr-x    1 root     root        4.0K Dec 9 14:14 ..
-rw-r--r--    1 root     root           4 Dec 10 16:36 IDConnectorService.pid

So there is an old PID File exist, go further with reset the state in the container.

  1. /etc/init.d/ucsschool-id-connector stop
  2. /etc/init.d/ucsschool-id-connector zap
  3. /etc/init.d/ucsschool-id-connector start

Connect out of the container with cntr+d and check again the container logs, to see that the ID-Connector works again and the error is fixed.
univention-app logs ucsschool-id-connector

Mastodon