Bug#950236: activemq: missing-systemd-service-for-init.d-script

Andreas Henriksson andreas at fatal.se
Thu Jan 30 11:48:44 GMT 2020


Source: activemq
Version: 5.15.11-1
Severity: normal

Dear Maintainer,

Please consider providing a native systemd service masking the
activemq init script (fixes lintian tag in subject).

I tried my best with what I could come up with by just looking at
how the init script currently seem to work. My completely untested
service file will be attached. (I don't personally use activemq.)
Hopefully it can be a useful starting point for you. Please don't
hesitate to reach out for help, I'll happily help out with improvements
if you provide the testing and review.
(README.Debian section "Setup a new ActiveMQ instance" likely
also needs tweaking a bit.)

Additionally to the template unit, something will need to enable
the actual instances. I suggest you do a one-time convertion
in the maintainer scripts (postinst) when upgrading to the new (first)
version that ships a native systemd unit (and enable the "main" instance
on new installs only).
Finally symlink activemq.service to /dev/null to mask the init script
as the templated instances will not do so automatically.

Additional comments on your init script:
- Please, please, please get rid of the NO_START anti-pattern, see
https://lintian.debian.org/tags/init.d-script-should-always-start-service.html
- Many small improvements can be made, like making `sed 's at .pid@@'` more
  explicit my matching on end of string, eg. `sed 's at .pid@@'`.
  You could also try using find with options like -type f or -type d and
  -maxdepth 1 as a replacement for ls and simplify your scripting.

Regards,
Andreas Henriksson
-------------- next part --------------
[Unit]
Description=Apache ActiveMQ
After=network.target

[Service]
Type=forking
PIDFile=/run/activemq/%I.pid
RuntimeDirectory=activemq
Environment=INSTANCE=%I
Environment=ACTIVEMQ_BASE=/var/lib/activemq/%I
Environment=ACTIVEMQ_PIDFILE=/run/activemq/%I.pid
Environment=ACTIVEMQ_CONFIG_DIR=/etc/activemq/instances-enabled/%I
WorkingDirectory=/usr/share/activemq
# Upstreams "DAEMON" binary is really an init script.
# (Note: the debian init script explicitly sources (activemq-)options
# files, but the DAEMON script will do that itself. Since it might need
# variable expansion we can't replace it with EnvironmentFile=...)
ExecStart=/usr/bin/activemq start
ExecStop=/usr/bin/activemq stop
Restart=on-failure
User=activemq
Group=activemq

[Install]
WantedBy=multi-user.target


More information about the pkg-java-maintainers mailing list