markdegrootnl / unifi-protect-arm64

Run UniFi Protect in Docker on ARM64 hardware
123 stars 25 forks source link

Protect app keeps restarting #27

Closed shred closed 6 months ago

shred commented 9 months ago

I'm trying to set up Unify protect. My setup: Odroid M1S, Ubuntu 20.04.6 LTS, /storage is on a 1TB NVMe with plenty of space. :smiley: The system is a fresh setup.

The installation itself went smoothly. However, when I reach the Applications dashboard, I can see that the "Protect" app is not starting:

screenshot

It shows "Starting" for several seconds, then falls back to a "Start" button, and immediately tries to start again. However it never reaches a state where it is completey started and I can setup the app.

Docker logs nothing at all. Unify OS' own log shows nothing of relevance. top shows that unify-protectis consuming about 150% CPU power.

What can I do?

Thank you for your help and for this great Docker image!

shred commented 9 months ago

Okay, I found a log output inside the docker container's journal:

Jan 06 10:06:07 server systemd[1]: Starting UniFi Protect...
Jan 06 10:06:07 server su[26852]: (to postgres) root on none
Jan 06 10:06:07 server su[26852]: pam_unix(su:session): session opened for user postgres(uid=104) by (uid=0)
Jan 06 10:06:07 server pre-start[26854]: createuser: error: creation of new role failed: ERROR:  role "unifi-protect" already exists
Jan 06 10:06:07 server su[26852]: pam_unix(su:session): session closed for user postgres
Jan 06 10:06:07 server pre-start[26851]: Journal log saved to /tmp/.lastProtectJournal
Jan 06 10:06:18 server node[26894]: CONFIG LOADED : /usr/share/unifi-protect/app/config/config.json
Jan 06 10:06:19 server node[26894]: Using unifi core certificate
Jan 06 10:06:19 server node[26894]: {
Jan 06 10:06:19 server node[26894]:   crt: '/data/unifi-core/config/unifi-core.crt',
Jan 06 10:06:19 server node[26894]:   key: '/data/unifi-core/config/unifi-core.key',
Jan 06 10:06:19 server node[26894]:   deviceCrt: '/srv/unifi-protect/data/devices.crt',
Jan 06 10:06:19 server node[26894]:   deviceKey: '/srv/unifi-protect/data/devices.key'
Jan 06 10:06:19 server node[26894]: }
Jan 06 10:06:38 server sudo[27464]: unifi-protect : PWD=/usr/share/unifi-protect ; USER=root ; COMMAND=/sbin/ubnt-tools id
Jan 06 10:06:38 server sudo[27464]: pam_unix(sudo:session): session opened for user root(uid=0) by (uid=997)
Jan 06 10:06:38 server sudo[27464]: pam_unix(sudo:session): session closed for user root
Jan 06 10:06:41 server node[26894]: (node:26894) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 21 item.save listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit
Jan 06 10:06:41 server node[26894]: (Use `node --trace-warnings ...` to show where the warning was created)
Jan 06 10:06:42 server bash[27561]: 27531 (process ID) old priority 0, new priority -10
Jan 06 10:06:42 server bash[27561]: 27559 (process ID) old priority 0, new priority -10
Jan 06 10:06:42 server systemd[1]: Started UniFi Protect.
Jan 06 10:06:45 server node[26894]: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Jan 06 10:06:45 server node[26894]: TypeError: Cannot read properties of null (reading 'writeThroughput')
Jan 06 10:06:45 server node[26894]:     at /usr/share/unifi-protect/app/webpack:/unifi-protect/src/middleware/ucore/index.js:136:33
Jan 06 10:06:47 server node[26894]: [PROD] Successfully sent 1 traces
Jan 06 10:06:49 server systemd[1]: var-opt-unifi\x2dprotect-tmp.mount: Succeeded.
Jan 06 10:06:49 server systemd[1]: unifi-protect.service: Succeeded.
Jan 06 10:06:55 server systemd[1]: unifi-protect.service: Scheduled restart job, restart counter is at 30.
Jan 06 10:06:55 server systemd[1]: Stopped UniFi Protect.
shred commented 6 months ago

The problem is that the Ubuntu kernel of Odroid M1S is compiled without IO Accounting. Unifi-Protect tries to access /proc/$PID/io, and then fails reading writeThroughput because that file is missing.

A quick check if the kernel is compiled with IO Accounting is via iotop. It fails on the M1S with Ubuntu kernel:

# iotop
Could not run iotop as some of the requirements are not met:
- Linux >= 2.6.20 with
  - I/O accounting support (CONFIG_TASKSTATS, CONFIG_TASK_DELAY_ACCT, CONFIG_TASK_IO_ACCOUNTING)

The fix is to either build a new kernel with the options mentioned above, or to use the Debian image.