Ubuntu Server 16.04.5 - Service will not AutoStart

I have installed Version 2018.10.08.2134 on Ubuntu Server 16.04.5 in a virtual machine on ESXi 6.0. The ESXi server is passing through an LSI controller card with 5 hard drives connected, which are configured in a ZFS volume to store all recordings. The setup script for the DVR server was run in a user home directory so the DVR server is installed into ~/channels-dvr.

Attached is an image with output showing that the service is not initially running, but is running after manually starting the service.

13%20AM

Sounds like maybe /home is a mount? The service is trying to start before the directory is mounted I think.

What does the mount command show.

The user home directory is encrypted.

On a side note, from looking at the logs it looked like the automatic attempts to restart were happening too fast and would eventually stop. I was able to get the DVR service to start with a hack by adding the following line to the channels-dvr.service in order to delay restarting:

RestartSec=10

Below is some of the output from the logs relevant to the DVR server after making the change. Looks like it is able to autostart on the 3rd attempt. Maybe it takes this amount of time for the home folder to be decrypted and available?

Nov 04 12:27:33 DVR systemd[1]: Started Channels DVR.
Nov 04 12:27:33 DVR systemd[1]: Starting /etc/rc.local Compatibility...
Nov 04 12:27:33 DVR systemd[2902]: channels-dvr.service: Failed at step CHDIR spawning /bin/sh: No such file or directory
Nov 04 12:27:33 DVR systemd[1]: Starting Plex Media Server for Linux...
Nov 04 12:27:33 DVR systemd[1]: Starting iSCSI initiator daemon (iscsid)...
Nov 04 12:27:33 DVR systemd[1]: channels-dvr.service: Main process exited, code=exited, status=200/CHDIR
Nov 04 12:27:33 DVR systemd[1]: channels-dvr.service: Unit entered failed state.
Nov 04 12:27:33 DVR systemd[1]: channels-dvr.service: Failed with result 'exit-code'.

...

Nov 04 12:27:43 DVR systemd[1]: channels-dvr.service: Service hold-off time over, scheduling restart.
Nov 04 12:27:43 DVR systemd[1]: Stopped Channels DVR.
Nov 04 12:27:43 DVR systemd[1]: Started Channels DVR.
Nov 04 12:27:43 DVR systemd[3191]: channels-dvr.service: Failed at step CHDIR spawning /bin/sh: No such file or directory
Nov 04 12:27:43 DVR systemd[1]: channels-dvr.service: Main process exited, code=exited, status=200/CHDIR
Nov 04 12:27:43 DVR systemd[1]: channels-dvr.service: Unit entered failed state.
Nov 04 12:27:43 DVR systemd[1]: channels-dvr.service: Failed with result 'exit-code'.

...

Nov 04 12:27:54 DVR systemd[1]: channels-dvr.service: Service hold-off time over, scheduling restart.
Nov 04 12:27:54 DVR systemd[1]: Stopped Channels DVR.
Nov 04 12:27:54 DVR systemd[1]: Started Channels DVR.

You could install into /usr/local instead.

Depending on the encryption daemon used, you can also add a dependency in the service file so it doesn't attempt to start until /home is available.

There are some workarounds in https://bugs.launchpad.net/ecryptfs/+bug/1734290

I've added this to our installer. The default is 100ms which is very aggressive.