TL;DR: custom systemd unit files can not have "-" in their name, or at least mine can't.
I like to have third-party software installed in a version-specific directory. In particular, I'm trying to get Elasticsearch to live in /opt/elasticsearch-2.4.0/ with a symlink /opt/elasticsearch -> /opt/elasticsearch-2.4.0, especially for service software that I might need to run multiple versions. I'm using Ubuntu 16.04 (Xenial/LTS) so I'm forced to deal with systemd files that are not delivered OOTTB. For comparison, I can install the .deb that elastic.co distributes, but that installs itself in /usr/, which means only one version.
Fortunately, the unit file is very simple:
I save this as /usr/lib/systemd/system/elasticsearch-2.4.0.service, and... nothing happens. Install the .deb, check that it has the right unit files (starts service ok). copy /usr/lib/systemd/system/elasticsearch.service as elasticsearch-2.4.0.service -- This should use the exact same config options, just run with a different service name, and nothing. Purge the .deb and put my unit file (above) in elasticsearch.service, and it runs.
The closest I can come to documentation of why servicename -dash- something is in the man page:
Some unit names reflect paths existing in the file system namespace. Example: a device unit dev-sda.device [...]So there might be something special about unit names with a dash in them? Hmm, mv elasticsearch.service elasticsearch_2.4.0.service ; systemctl daemon-reload ; service elasticsearch_2.4.0 start. By golly, that works.
I guess I'll change the service naming. (But note, cfengine3-web is apparently a perfectly valid systemd unit name for CFEngine Enterprise)